]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
dup.2: ffix
authorMichael Kerrisk <mtk.manpages@gmail.com>
Wed, 10 Jun 2020 09:48:44 +0000 (11:48 +0200)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Wed, 10 Jun 2020 09:48:44 +0000 (11:48 +0200)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man2/dup.2

index c997fc975d5719dc1c91e517058e1036638ce0ea..56cdb6547ae66f5c13c9a2155c08523afb95b9f5 100644 (file)
@@ -247,31 +247,33 @@ before calling
 because of the race condition described above.
 Instead, code something like the following could be used:
 .PP
+.in +4n
 .EX
-    /* Obtain a duplicate of 'newfd' that can subsequently
-       be used to check for close() errors; an EBADF error
-       means that 'newfd' was not open. */
+/* Obtain a duplicate of 'newfd' that can subsequently
+   be used to check for close() errors; an EBADF error
+   means that 'newfd' was not open. */
 
-    tmpfd = dup(newfd);
-    if (tmpfd == \-1 && errno != EBADF) {
-        /* Handle unexpected dup() error */
-    }
+tmpfd = dup(newfd);
+if (tmpfd == \-1 && errno != EBADF) {
+    /* Handle unexpected dup() error */
+}
 
-    /* Atomically duplicate 'oldfd' on 'newfd' */
+/* Atomically duplicate 'oldfd' on 'newfd' */
 
-    if (dup2(oldfd, newfd) == \-1) {
-        /* Handle dup2() error */
-    }
+if (dup2(oldfd, newfd) == \-1) {
+    /* Handle dup2() error */
+}
 
-    /* Now check for close() errors on the file originally
-       referred to by 'newfd' */
+/* Now check for close() errors on the file originally
+   referred to by 'newfd' */
 
-    if (tmpfd != \-1) {
-        if (close(tmpfd) == \-1) {
-            /* Handle errors from close */
-        }
+if (tmpfd != \-1) {
+    if (close(tmpfd) == \-1) {
+        /* Handle errors from close */
     }
+}
 .EE
+.in
 .SH SEE ALSO
 .BR close (2),
 .BR fcntl (2),