DUP(2) DOMAIN/IX Reference Manual (SYS5) DUP(2)
NAME
dup - duplicate an open file descriptor
USAGE
int dup (fildes)
int fildes;
DESCRIPTION
Fildes is the name of a file descriptor returned by a creat,
open, dup, fcntl, or pipe system call. Dup returns a new
file descriptor with the following characteristics in common
with the original:
Same open file (or pipe).
Same file pointer (i.e., both file descriptors share
one file pointer).
Same access mode (read, write, or read/write).
The new file descriptor remains open across exec system
calls. See fcntl(2).
The file descriptor returned is given the lowest number
available.
RETURN VALUE
Dup returns a non-negative integer, the file descriptor,
upon successful completion. Otherwise, it returns -1 and
sets errno to specify the error.
ERRORS
Dup fails if one or more of the following is true:
[EBADF] Fildes is not a valid open file descriptor.
[EMFILE] The maximum number of open file descriptors
allowed would be exceeded.
RELATED INFORMATION
creat(2), close(2), exec(2), fcntl(2), open(2), pipe(2)
Printed 5/10/85 DUP-1