cloexec returns int not bool, to be more consistent with Unix conventions.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Mar 2004 23:59:03 +0000 (23:59 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Mar 2004 23:59:03 +0000 (23:59 +0000)
lib/ChangeLog
lib/cloexec.c
lib/cloexec.h

index 75c4123fbbd530e064374e27eebf261618a3d29a..863666ceb5d2e0246afe187348dce0f80ec08fa1 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-30  Paul Eggert  <eggert@twinsun.com>
+
+       * lib/cloexec.h, lib/cloexec.c (set_cloexec_flag): Return int
+       not bool, to be more consistent with Unix conventions.
+       Suggested by Bruno Haible.
+
 2004-03-30  Bruno Haible  <bruno@clisp.org>
 
        * getloadavg.c (getloadavg): Don't assume setlocale returns
index 20f30db45d868321f6d7c8a3728b9030e3ff37ac..e07cdd3d5daf3001da6017c8625f44364cc8b907 100644 (file)
 
 /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
    or clear the flag if VALUE is false.
-   Return true on success, or false on error with `errno' set. */
+   Return 0 on success, or -1 on error with `errno' set. */
 
-bool
+int
 set_cloexec_flag (int desc, bool value)
 {
 #if defined F_GETFD && defined F_SETFD
 
   int flags = fcntl (desc, F_GETFD, 0);
-  int newflags;
 
-  if (flags < 0)
-    return false;
+  if (0 <= flags)
+    {
+      int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
 
-  newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
+      if (flags == newflags
+         || fcntl (desc, F_SETFD, newflags) != -1)
+       return 0;
+    }
 
-  return (flags == newflags
-         || fcntl (desc, F_SETFD, newflags) != -1);
+  return -1;
 
 #else
 
-  return true;
+  return 0;
 
 #endif
 }
index ecad8d712f739626eb9cf1c405c34400c5053ede..c25921d6b375567d668f6a88c156ad2ce30c18d6 100644 (file)
@@ -1,2 +1,2 @@
 #include <stdbool.h>
-bool set_cloexec_flag (int desc, bool value);
+int set_cloexec_flag (int desc, bool value);