dup2(S-osr5)
dup2 --
duplicate an open file descriptor
Syntax
cc . . . -lc
int dup2 (fildes, fildes2)
int fildes, fildes2;
Description
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:
[EBADF]-
fildes is not a valid open file descriptor.
[EINTR]-
a signal was caught during the
dup2()
call.
[EMFILE]-
_NFILE file descriptors are currently open.
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.
See also
creat(S-osr5),
close(S-osr5),
exec(S-osr5),
fcntl(S-osr5),
lockf(S-osr5),
open(S-osr5),
pipe(S-osr5)
Standards conformance
dup2 is conformant with:
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1)
;
and
NIST FIPS 151-1
.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005