Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     DUP(S)                    UNIX System V                    DUP(S)



     Name
          dup - duplicate an open file descriptor

     Syntax
          int dup (fildes)
          int fildes;

     Description
          The fildes argument is a file descriptor obtained from a
          creat, open, dup, fcntl, or pipe system call.  The dup
          system call returns a new file descriptor having the
          following in common with the original:

               Same open file (or pipe)

               Same file pointer (that is, both file descriptors share
               one file pointer)

               Same access mode (read, write, or read/write)

          The new file descriptor is set to remain open across exec
          system calls (see fcntl(S)).

          The file descriptor returned is the lowest one available.

          The dup system call will fail if one or more of the
          following is true:

          [EBADF]        The fildes argument is not a valid open file
                         descriptor.

          [EINTR]        A signal was caught during the dup system
                         call.

          [EMFILE]       NOFiles file descriptors are currently open.

          [ENOLINK]      fildes is on a remote machine and the link to
                         that machine is no longer active.

     See Also
          close(S), creat(S), exec(S), fcntl(S), open(S), pipe(S),
          lockf(S)

     Diagnostics
          Upon successful completion a non-negative integer, namely
          the file descriptor, is returned.  Otherwise, a value of -1
          is returned, and errno is set to indicate the error.

     Standards Conformance
          dup is conformant with:
          AT&T SVID Issue 2, Select Code 307-127;
          The X/Open Portability Guide II of January 1987;
          IEEE POSIX Std 1003.1-1988 with C Standard Language-
          Dependent System Support;
          and NIST FIPS 151-1.

                                                (printed 6/20/89)



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