Query: dup2
OS: plan9
Section: 3c
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
dup2(3C) Standard C Library Functions dup2(3C)NAMEdup2 - duplicate an open file descriptorSYNOPSIS#include <unistd.h> int dup2(int fildes, int fildes2);DESCRIPTIONThe dup2() function causes the file descriptor fildes2 to refer to the same file as fildes. The fildes argument is a file descriptor refer- ring to an open file, and fildes2 is a non-negative integer less than the current value for the maximum number of open file descriptors allowed the calling process. See getrlimit(2). If fildes2 already refers to an open file, not fildes, it is closed first. If fildes2 refers to fildes, or if fildes is not a valid open file descriptor, fildes2 will not be closed first. The dup2() function is equivalent to fcntl(fildes, F_DUP2FD, fildes2).RETURN VALUESUpon successful completion a non-negative integer representing the file descriptor is returned. Otherwise, -1 is returned and errno is set to indicate the error.ERRORSThe dup2() function will fail if: EBADF The fildes argument is not a valid open file descriptor. EBADF The files2 argument is negative or is not less than the current resource limit returned by getrlimit(RLIMIT_NOFILE, ...). EINTR A signal was caught during the dup2() call. EMFILE The process has too many open files. See fcntl(2).ATTRIBUTESSee attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+SEE ALSOclose(2), creat(2), exec(2), fcntl(2), getrlimit(2), open(2), pipe(2), lockf(3C), attributes(5), standards(5) SunOS 5.10 19 Dec 2003 dup2(3C)
Related Man Pages |
---|
dup(2) - mojave |
dup(3) - linux |
dup2(2) - osx |
dup2(3c) - xfree86 |
dup2(3c) - plan9 |
Similar Topics in the Unix Linux Community |
---|
File status - open/close ?? |
Find and Replace |
Writing from STDIN_FILENO to a file |
a issue with dup2 |
dup2 filedescriptor redirecting output |