The dup() function returns a new file descriptor having the following in common with the original open file descriptor fildes:
- 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 functions (see fcntl(2)).
The file descriptor returned is the lowest one available.
The dup(fildes) function call is equivalent to:
fcntl(fildes, F_DUPFD, 0)
|