Manual Page Result
0
Command: dup | Section: 2 | Source: UNIX v10 | File: dup.2
DUP(2) System Calls Manual DUP(2)
NAME
dup, dup2 - duplicate an open file descriptor
SYNOPSIS
int dup(fildes)
int fildes;
int dup2(fildes, fildes2)
int fildes, fildes2;
DESCRIPTION
Given a file descriptor dup allocates another file descriptor synony-
mous with the original. The new file descriptor is returned.
In dup2, fildes is a file descriptor referring to an open file, and
fildes2 is an integer in the range of legal file descriptors. Dup2
causes fildes2 to refer to the same file and returns fildes2. If
fildes2 already referred to another open file, it is closed first.
SEE ALSO
open(2), pipe(2), fd(4)
DIAGNOSTICS
EBADF, EMFILE
BUGS
Dup of a file descriptor greater than 63 turns into a dup2 with a ran-
dom second argument.
DUP(2)