duplicate an open file descriptor
cc . . . -lc
int dup2 (fildes, fildes2)
int fildes, fildes2;
The fildes argument is a
file descriptor referring to an open file, and
fildes2 is a non-negative integer less than
_NFILE. dup2 causes fildes2 to refer
to the same file as fildes. If fildes2
already referred to an open file, it is closed first.
The dup2 function fails if one or more of the following is true:
fildes is not a valid open file descriptor.
a signal was caught during the
_NFILE file descriptors are currently open.
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.
dup2 is conformant with:
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