DUP(2) SYSTEM CALLS DUP(2)
NAME
dup -- duplicate an open file descriptor
SYNOPSIS
#include <unistd.h>
int dup(int fildes);
SYNOPSIS <in case of float1/float2 non-ANSI C>
int dup(fildes)
int fildes
DESCRIPTION
fildes is a file descriptor obtained from a creat(2),
open(2), dup(2), fcntl(2), or pipe(2) system call. dup
returns a new file descriptor that has the following in com-
mon with the original:
The same open file (or pipe)
The same file pointer (both file descriptors share one
file pointer)
The same access mode (read, write or read/write)
The new file descriptor is set to remain open across exec(2)
system calls. See fcntl(2).
The file descriptor returned is the lowest one available.
dup fails if one or more of the following are true.
[EBADF] fildes is not a valid open file descriptor.
[EINTR] A signal was caught during the dup system
call.
[EMFILE] The process/job has too many open files [see
getrlimit(2)].
[ENOLINK] fildes is on a remote machine, and the link
to that machine is no longer active.
SEE ALSO
close(2), creat(2), exec(2), fcntl(2), open(2), pipe(2),
lockf(3C)
SUPER-UX Last change: Nov 12, 1996 1
DUP(2) SYSTEM CALLS DUP(2)
DIAGNOSTICS
Upon successful completion a non-negative integer (the file
descriptor) is returned. Otherwise, a value of -1 is
returned, and errno is set to indicate the error.
SUPER-UX Last change: Nov 12, 1996 2
G1AB02E Programmer's Reference Manual