mirror of https://github.com/mkerrisk/man-pages
Reordered text in DESCRIPTION and added some details for dup2().
This commit is contained in:
parent
fd48405669
commit
a4e3b1bc3e
40
man2/dup.2
40
man2/dup.2
|
@ -1,7 +1,8 @@
|
|||
.\" Hey Emacs! This file is -*- nroff -*- source.
|
||||
.\"
|
||||
.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
|
||||
.\" 1993 Michael Haardt, Ian Jackson.
|
||||
.\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
|
||||
.\" and Copyright (C) 2005, 2008 Michael Kerrisk <mtk.manpages@gmail.com>
|
||||
.\"
|
||||
.\" Permission is granted to make and distribute verbatim copies of this
|
||||
.\" manual provided the copyright notice and this permission notice are
|
||||
|
@ -28,8 +29,10 @@
|
|||
.\" Fixed typoes.
|
||||
.\" Modified 1997-01-31, Eric S. Raymond <esr@thyrsus.com>
|
||||
.\" Modified 2002-09-28, aeb
|
||||
.\" 2009-01-12, mtk, reordered text in DESCRIPTION and added some
|
||||
.\" details for dup2().
|
||||
.\"
|
||||
.TH DUP 2 1994-08-21 "Linux" "Linux Programmer's Manual"
|
||||
.TH DUP 2 2008-01-12 "Linux" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
dup, dup2 \- duplicate a file descriptor
|
||||
.SH SYNOPSIS
|
||||
|
@ -46,6 +49,30 @@ and
|
|||
create a copy of the file descriptor
|
||||
.IR oldfd .
|
||||
|
||||
.BR dup ()
|
||||
uses the lowest-numbered unused descriptor for the new descriptor.
|
||||
|
||||
.BR dup2 ()
|
||||
.RI "makes " newfd " be the copy of " oldfd ", closing " newfd
|
||||
first if necessary, but note the following:
|
||||
.IP * 3
|
||||
If
|
||||
.I olfd
|
||||
is not a valid file descriptor, then the call fails, and
|
||||
.I newfd
|
||||
is not closed.
|
||||
.IP *
|
||||
If
|
||||
.I oldfd
|
||||
is a valid file descriptor, and
|
||||
.I newfd
|
||||
has the same value as
|
||||
.IR oldfd ,
|
||||
then
|
||||
.BR dup2 ()
|
||||
does nothing, and returns
|
||||
.IR newfd .
|
||||
.PP
|
||||
After a successful return from
|
||||
.BR dup ()
|
||||
or
|
||||
|
@ -65,13 +92,6 @@ The close-on-exec flag
|
|||
see
|
||||
.BR fcntl (2))
|
||||
for the duplicate descriptor is off.
|
||||
|
||||
.BR dup ()
|
||||
uses the lowest-numbered unused descriptor for the new descriptor.
|
||||
|
||||
.BR dup2 ()
|
||||
.RI "makes " newfd " be the copy of " oldfd ", closing " newfd
|
||||
first if necessary.
|
||||
.SH "RETURN VALUE"
|
||||
.BR dup ()
|
||||
and
|
||||
|
@ -127,7 +147,7 @@ If
|
|||
.I newfd
|
||||
was open, any errors that would have been reported at
|
||||
.BR close (2)
|
||||
time, are lost.
|
||||
time are lost.
|
||||
A careful programmer will not use
|
||||
.BR dup2 ()
|
||||
without closing
|
||||
|
|
Loading…
Reference in New Issue