summaryrefslogtreecommitdiffstats
path: root/man2/dup.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/dup.2')
-rw-r--r--man2/dup.238
1 files changed, 23 insertions, 15 deletions
diff --git a/man2/dup.2 b/man2/dup.2
index 85dac61ff..b7187ed59 100644
--- a/man2/dup.2
+++ b/man2/dup.2
@@ -14,7 +14,7 @@
.\" details for dup2().
.\" 2008-10-09, mtk: add description of dup3()
.\"
-.TH dup 2 2023-02-05 "Linux man-pages 6.03"
+.TH dup 2 2023-05-03 "Linux man-pages 6.05.01"
.SH NAME
dup, dup2, dup3 \- duplicate a file descriptor
.SH LIBRARY
@@ -197,20 +197,28 @@ The per-process limit on the number of open file descriptors has been reached
.B RLIMIT_NOFILE
in
.BR getrlimit (2)).
-.SH VERSIONS
-.BR dup3 ()
-was added in Linux 2.6.27;
-glibc support is available since glibc 2.9.
.SH STANDARDS
-.BR dup (),
-.BR dup2 ():
-POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
-.PP
+.TP
+.BR dup ()
+.TQ
+.BR dup2 ()
+POSIX.1-2008.
+.TP
.BR dup3 ()
-is Linux-specific.
+Linux.
+.SH HISTORY
+.TP
+.BR dup ()
+.TQ
+.BR dup2 ()
+POSIX.1-2001, SVr4, 4.3BSD.
.\" SVr4 documents additional
.\" EINTR and ENOLINK error conditions. POSIX.1 adds EINTR.
.\" The EBUSY return is Linux-specific.
+.TP
+.BR dup3 ()
+Linux 2.6.27,
+glibc 2.9.
.SH NOTES
The error returned by
.BR dup2 ()
@@ -247,21 +255,21 @@ Instead, code something like the following could be used:
/* Obtain a duplicate of \[aq]newfd\[aq] that can subsequently
be used to check for close() errors; an EBADF error
means that \[aq]newfd\[aq] was not open. */
-
+\&
tmpfd = dup(newfd);
if (tmpfd == \-1 && errno != EBADF) {
/* Handle unexpected dup() error. */
}
-
+\&
/* Atomically duplicate \[aq]oldfd\[aq] on \[aq]newfd\[aq]. */
-
+\&
if (dup2(oldfd, newfd) == \-1) {
/* Handle dup2() error. */
}
-
+\&
/* Now check for close() errors on the file originally
referred to by \[aq]newfd\[aq]. */
-
+\&
if (tmpfd != \-1) {
if (close(tmpfd) == \-1) {
/* Handle errors from close. */