Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
dup2(2)
Edit
PageHistory
Diff
Info
LikePages
You are viewing an old revision of this page.
View the current version
.
DUP !!!DUP NAME SYNOPSIS DESCRIPTION RETURN VALUE ERRORS WARNING CONFORMING TO SEE ALSO ---- !!NAME dup, dup2 - duplicate a file descriptor !!SYNOPSIS __#include __ ''oldfd''__); int dup2(int__ ''oldfd''__, int__ ''newfd''__); __ !!DESCRIPTION __dup__ and __dup2__ create a copy of the file descriptor ''oldfd''. After successful return of __dup__ or __dup2__, 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__ on one of the descriptors, the position is also changed for the other. The two descriptors do not share the close-on-exec flag, however. __dup__ uses the lowest-numbered unused descriptor for the new descriptor. __dup2__ makes ''newfd'' be the copy of ''oldfd'', closing ''newfd'' first if necessary. !!RETURN VALUE __dup__ and __dup2__ return the new descriptor, or -1 if an error occurred (in which case, ''errno'' is set appropriately). !!ERRORS __EBADF__ ''oldfd'' isn't an open file descriptor, or ''newfd'' is out of the allowed range for file descriptors. __EMFILE__ The process already has the maximum number of file descriptors open and tried to open a new one. !!WARNING The error returned by __dup2__ is different to that returned by __fcntl(__..., __F_DUPFD__, ...__)__ when ''newfd'' is out of range. On some systems __dup2__ also sometimes returns __EINVAL__ like __F_DUPFD__. !!CONFORMING TO SVr4, SVID, POSIX, X/OPEN, BSD 4.3. SVr4 documents additional EINTR and ENOLINK error conditions. POSIX.1 adds EINTR. !!SEE ALSO fcntl(2), open(2), close(2) ----
3 pages link to
dup2(2)
:
fcntl(2)
Man2d
syscalls(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.