]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
Consistent use of terms "open file description",
authorMichael Kerrisk <mtk.manpages@gmail.com>
Wed, 22 Jun 2005 09:53:00 +0000 (09:53 +0000)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Wed, 22 Jun 2005 09:53:00 +0000 (09:53 +0000)
"file status flags", and "file decriptor flags"
Removed mention of lock sharing -- it was not accurate.
Minor formatting fixes

man2/dup.2

index 1d378d1e48eaddb34b9b6af50b7bf4b4c87271bb..3739844b92bc2a99f5763c90f4323b2f31415400 100644 (file)
@@ -40,27 +40,35 @@ dup, dup2 \- duplicate a file descriptor
 .BI "int dup2(int " oldfd ", int " newfd );
 .fi
 .SH DESCRIPTION
-.BR dup " and " dup2
+.BR dup "() and " dup2 ()
 create a copy of the file descriptor
 .IR oldfd .
 
-After successful return of \fBdup\fR or \fBdup2\fR,
-the old and new descriptors may be used interchangeably. They share
-locks, file position pointers and flags; for example, if the file
-position is modified by using
-.B lseek
+After a successful return from \fBdup\fR() or \fBdup2\fR(),
+the old and new file descriptors may be used interchangeably.
+They refer to the same open file description (see
+.BR open (2))
+and thus share file offset and file status flags;
+for example, if the file offset is modified by using
+.BR lseek (2)
 on one of the descriptors, the position is also changed for the other.
 
-The two descriptors do not share the close-on-exec flag, however.
+The two descriptors do not share file descriptor flags
+(the close-on-exec flag).
+The close-on-exec flag 
+.RB ( FD_CLOEXEC ; 
+see
+.BR fcntl (2))
+for the duplicate descriptor is off.
 
-.B dup
+.BR dup ()
 uses the lowest-numbered unused descriptor for the new descriptor.
 
-.B dup2
+.BR dup2 ()
 .RI "makes " newfd " be the copy of " oldfd ", closing " newfd
 first if necessary.
 .SH "RETURN VALUE"
-.BR dup " and " dup2
+.BR dup "() and " dup2 ()
 return the new descriptor, or \-1 if an error occurred (in which case,
 .I errno
 is set appropriately).
@@ -74,37 +82,37 @@ is out of the allowed range for file descriptors.
 .TP
 .B EBUSY
 (Linux only) This may be returned by
-.B dup2
+.BR dup2 ()
 during a race condition with open() and dup().
 .TP
 .B EINTR
 The
-.B dup2
+.BR dup2 ()
 call was interrupted by a signal.
 .TP
 .B EMFILE
 The process already has the maximum number of file
 descriptors open and tried to open a new one.
-.SH WARNING
+.SH WARNINGS
 The error returned by
-.B dup2
+.BR dup2 ()
 is different from that returned by
 .BR fcntl( "..., " F_DUPFD ", ..." )
 when
 .I newfd
 is out of range. On some systems
-.B dup2
+.BR dup2 ()
 also sometimes returns
 .B EINVAL
 like
 .BR F_DUPFD .
-.SH BUGS
+
 If
 .I newfd
 was open, any errors that would have been reported at
 .IR close ()
 time, are lost. A careful programmer will not use
-.B dup2
+.BR dup2 ()
 without closing
 .I newfd
 first.