.TH dup() "" "" "System Call (libc)"
.PC "Duplicate a file descriptor"
.B "#include <unistd.h>"
\fBint dup(\fIfd\^\fB) int \fIfd\^\fB;\fR
.PP
.B dup()
duplicates the existing file descriptor
.IR fd ,
and returns the new descriptor.
The returned value is the smallest
file descriptor that is not already in use by the calling process.
.SH "See Also"
.Xr "dup2()," dup2
.Xr "fopen()," fopen
.Xr "fdopen()," fdopen
.Xr "libc," libc
.Xr "stdio.h," stdio.h
.Xr "unistd.h" unistd.h
.br
\*(PX Standard, \(sc6.2.1
.SH Diagnostics
.B dup()
returns a number less than zero when an error occurs,
such as a bad file descriptor or no file descriptor available.
