| Rev | Author | # | Line |
|---|---|---|---|
| 1 | perry | 1 | !!NAME |
| 2 | |||
| 3 | dup, dup2 - duplicate a file descriptor | ||
| 4 | !!SYNOPSIS | ||
| 5 | |||
| 6 | |||
| 2 | PerryLorier | 7 | __#include <unistd.h>__ |
| 8 | __int dup(int__ ''oldfd''__);__ | ||
| 1 | perry | 9 | |
| 10 | !!DESCRIPTION | ||
| 11 | |||
| 2 | PerryLorier | 12 | __dup__ create a copy of the file descriptor ''oldfd''. |
| 1 | perry | 13 | |
| 14 | |||
| 2 | PerryLorier | 15 | After successful return of __dup__, the old and new descriptors may be used interchangeably. They share locks, file position pointers and flags; for example, if the file position is modified by using lseek(2) on one of the descriptors, the position is also changed for the other. |
| 1 | perry | 16 | |
| 2 | PerryLorier | 17 | The two descriptors do __not__ share the close-on-exec flag, however. |
| 1 | perry | 18 | |
| 2 | PerryLorier | 19 | dup(2) uses the lowest-numbered unused descriptor for the new descriptor. |
| 1 | perry | 20 | |
| 21 | !!RETURN VALUE | ||
| 22 | |||
| 2 | PerryLorier | 23 | __dup__ returns the new descriptor, or -1 if an error occurred (in which case, ''errno'' is set appropriately). |
| 1 | perry | 24 | |
| 25 | !!ERRORS | ||
| 26 | |||
| 2 | PerryLorier | 27 | ;[EBADF]: ''oldfd'' isn't an open file descriptor |
| 28 | ;[EMFILE]: The process already has the maximum number of file descriptors open and tried to open a new one. | ||
| 1 | perry | 29 | |
| 30 | !!CONFORMING TO | ||
| 31 | |||
| 2 | PerryLorier | 32 | SVr4, SVID, POSIX, X/OPEN, BSD 4.3. SVr4 documents additional [EINTR] and [ENOLINK] error conditions. POSIX.1 adds [EINTR]. |
| 1 | perry | 33 | |
| 34 | !!SEE ALSO | ||
| 35 | |||
| 2 | PerryLorier | 36 | fcntl(2), open(2), close(2) |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 7 times)