duplicate an open file descriptor
cc . . . -lc
int dup (fildes)
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.
The file descriptor returned is the lowest one available.
The dup system call
fails if one or more of the following is true:
The fildes argument is not a valid open file descriptor.
A signal was caught during the dup system call.
NFILE file descriptors are currently open.
fildes is on a remote machine and the link
to that machine is no longer active.
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.
dup is conformant with:
X/Open Portability Guide, Issue 3, 1989
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1)
NIST FIPS 151-1
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003