]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
Reordered text in DESCRIPTION and added some details for dup2().
authorMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 12 Jan 2008 13:19:03 +0000 (13:19 +0000)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 12 Jan 2008 13:19:03 +0000 (13:19 +0000)
man2/dup.2

index 21955de42b6898701fe3399d5ff886cc36868c17..9163acc9438b94836eb22ed2dc6e61c7ddca1530 100644 (file)
@@ -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
 .\"   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