Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ dup2(2) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                  dup2(2)



        _________________________________________________________________
        dup2                                                  System Call
        Duplicate an open file descriptor onto a specific descriptor.
        _________________________________________________________________


        SYNTAX

        int    dup2  (old_fildes, new_fildes)
        int             old_fildes;
        int             new_fildes;


        PARAMETERS

        old_fildes     A valid, active file descriptor.


        new_fildes     Another file descriptor.


        DESCRIPTION

        Dup2 combines the functionality of the dup and close operations.

        If <old_fildes> is an active, valid descriptor and <new_fildes>
        is a valid descriptor (active or not), <new_fildes> is made a
        duplicate of <old_fildes>.  If <old_fildes> and <new_fildes>
        already refer to the same object pointer, no changes occur.  In
        all other situations in which <new_fildes> is active, it is
        closed before being made a duplicate of <old_fildes>.  The
        close-on-exec flag is set so the descriptor remains open across
        exec(2) operations.  For a further discussion of the semantics of
        duplication and closing, see the dup and close operations
        respectively.

        If <old_fildes> equals <new_fildes>, no changes occur.  However,
        an error will be returned if <old_fildes> is not an active, valid
        descriptor.


        ACCESS CONTROL

        None.


        RETURN VALUE

        <new_fildes>   The value of the new file descriptor given by
                       <new_fildes>.




        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                  dup2(2)



        -1             An error occurred.  Errno is set to indicate the
                       error.


        EXCEPTIONS

        Errno may be set to one of the following error codes:


        EBADF          <Old_fildes> is not a valid, active descriptor.


        EBADF          <New_fildes> is not a valid descriptor.


        SEE ALSO

        The related manual sections:  accept(2), close(2), creat(2),
        dup(2), exec(2), fcntl(2), getdtablesize(2), open(2), pipe(2),
        socket(2), socketpair(2).


































        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026