Penguin
Annotated edit history of dup2(2) version 3, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 dup2 - duplicate a file descriptor
1 perry 3
4 !!SYNOPSIS
2 PerryLorier 5 __#include <unistd.h>__
6 __int dup2(int__ ''oldfd''__, int__ ''newfd''__);__
1 perry 7
8 !!DESCRIPTION
2 PerryLorier 9 __dup2__ creates a copy of the file descriptor ''oldfd''.
1 perry 10
2 PerryLorier 11 After successful return of dup2(2), 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 12
2 PerryLorier 13 The two descriptors do not share the close-on-exec flag, however.
1 perry 14
2 PerryLorier 15 dup2(2) makes ''newfd'' be the copy of ''oldfd'', closing ''newfd'' first if necessary.
1 perry 16
17 !!RETURN VALUE
2 PerryLorier 18 __dup2__ returns the new descriptor, or -1 if an error occurred (in which case, ''errno'' is set appropriately).
1 perry 19
20 !!ERRORS
2 PerryLorier 21 ;[EBADF]: ''oldfd'' isn't an open file descriptor, or ''newfd'' is out of the allowed range for file descriptors.
22 ;[EMFILE]: The process already has the maximum number of file descriptors open and tried to open a new one.
1 perry 23
24 !!WARNING
2 PerryLorier 25 The error returned by dup2(2) is different to that returned by __fcntl(__..., __F_DUPFD__, ...__)__ (fcntl(2)) when ''newfd'' is out of range. On some systems dup2(2) also sometimes returns [EINVAL] like __F_DUPFD__.
1 perry 26
27 !!CONFORMING TO
3 JohnMcPherson 28 SVr4, SVID, [POSIX], X/OPEN, BSD 4.3. SVr4 documents additional [EINTR] and [ENOLINK] error conditions. POSIX.1 adds [EINTR].
1 perry 29
30 !!SEE ALSO
2 PerryLorier 31 fcntl(2), open(2), close(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 8 times)