Query: dup2
OS: ultrix
Section: 2
Links: ultrix man pages all man pages
Forums: unix linux community forum categories
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
dup(2) System Calls Manual dup(2) Name dup, dup2 - duplicate an open file descriptor Syntax newd = dup(oldd) int newd, oldd; dup2(oldd, newd) int oldd, newd; Description The system call duplicates an existing object descriptor. The argument oldd is a small non-negative integer index in the per-process descriptor table. The value must be less than the size of the table, which is returned by The new descriptor, newd, returned by the call is the lowest numbered descriptor that is not currently in use by the process. The object referenced by the descriptor does not distinguish between references using oldd and newd in any way. Thus, if newd and oldd are duplicate references to an open file, and calls all move a single pointer into the file. If a separate pointer into the file is desired, a different object reference to the file must be obtained by issuing an additional call. In the second form of the call, specify the value of newd needed. If this descriptor is already in use, the descriptor is first deallocated as if a call had been done. Return Values The value -1 is returned if an error occurs in either call. The external variable errno indicates the cause of the error. Diagnostics The and system calls fail under the following conditions: [EBADF] The oldd or newd is not a valid active descriptor. [EMFILE] Too many descriptors are active. [EINTR] The or function was terminated prematurely by a signal. See Also accept(2), close(2), getdtablesize(2), lseek(2), open(2), pipe(2), read(2), socket(2), socketpair(2), write(2) dup(2)
Related Man Pages |
---|
dup2(2) - mojave |
dup(2) - bsd |
dup2(2) - debian |
dup3(2) - netbsd |
dup2(2) - freebsd |
Similar Topics in the Unix Linux Community |
---|
dup() |
file pointer |
File Descriptor Table |
dup() |
Dup2 - for file descriptor opened by a different process |