changeset 12406:9cd471f81705

cloexec: Clarify code.
author Bruno Haible <bruno@clisp.org>
date Wed, 09 Dec 2009 11:21:35 +0100
parents fc655d62b4b9
children 311868bb0b6a
files ChangeLog lib/cloexec.c
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-12-09  Bruno Haible  <bruno@clisp.org>
+
+	* lib/cloexec.c (set_cloexec_flag): Clarify intent of dup2 call.
+
 2009-12-08  Eric Blake  <ebb9@byu.net>
 
 	fchdir: avoid memory leak on re-registration.
--- a/lib/cloexec.c
+++ b/lib/cloexec.c
@@ -71,8 +71,12 @@
       errno = EBADF;
       return -1;
     }
-  return dup2 (desc, desc) == desc ? 0 : -1;
+  if (dup2 (desc, desc) < 0)
+    /* errno is EBADF here.  */
+    return -1;
 
+  /* There is nothing we can do on this kind of platform.  Punt.  */
+  return 0;
 #endif
 }