| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- duplicate an open file descriptor
#include <unistd.h>intdup(intfildes);
Thedup() function returns a new file descriptor having the following incommon with the original open file descriptorfildes:
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 acrossexec functions(seefcntl(2)).
The file descriptor returned is the lowest one available.
Thedup(fildes) function call is equivalent to:
fcntl(fildes, F_DUPFD, 0)
Upon successful completion, a non-negative integer representing the file descriptor is returned.Otherwise,-1 is returned anderrno is set to indicate the error.
Thedup() function will fail if:
Thefildes argument is not a valid open file descriptor.
A signal was caught during the execution of thedup() function.
The process has too many open files (seegetrlimit(2)).
Thefildes argument is on a remote machine and the link to that machine is no longer active.
Seeattributes(5) for descriptions of the following attributes:
|
close(2),creat(2),exec(2),fcntl(2),getrlimit(2),open(2),pipe(2),dup2(3C),lockf(3C),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |