bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Move more flags to lib/fcntl.in.h


From: Paolo Bonzini
Subject: [PATCH] Move more flags to lib/fcntl.in.h
Date: Thu, 20 Aug 2009 10:27:02 +0200

While the discussion proceeds, what about this very tiny preliminary
step?

Paolo

2009-08-20  Paolo Bonzini  <address@hidden>

        * lib/cloexec.c: Do not define FD_CLOEXEC here.
        * lib/popen-safer.c: Do not alias O_NOINHERIT to O_CLOEXEC here.
        * lib/fcntl.in.h: Do both things here.
---
 ChangeLog         |    6 ++++++
 lib/cloexec.c     |    4 ----
 lib/fcntl.in.h    |   11 +++++++++++
 lib/popen-safer.c |    4 +---
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aae0ae0..9e40926 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-08-20  Paolo Bonzini  <address@hidden>
 
+       * lib/cloexec.c: Do not define FD_CLOEXEC here.
+       * lib/popen-safer.c: Do not alias O_NOINHERIT to O_CLOEXEC here.
+       * lib/fcntl.in.h: Do both things here.
+
+2009-08-20  Paolo Bonzini  <address@hidden>
+
        Fix polling for writeability of a screen buffer.
        * lib/poll.c: Distinguish input and screen buffers for the
        Win32 implementation.
diff --git a/lib/cloexec.c b/lib/cloexec.c
index ff8105b..0fb227c 100644
--- a/lib/cloexec.c
+++ b/lib/cloexec.c
@@ -24,10 +24,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#ifndef FD_CLOEXEC
-# define FD_CLOEXEC 1
-#endif
-
 /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
    or clear the flag if VALUE is false.
    Return 0 on success, or -1 on error with `errno' set. */
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index fd7520e..a688fb4 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -67,6 +67,11 @@ extern void _gl_register_fd (int fd, const char *filename);
 }
 #endif
 
+/* Fix up the FD_* macros.  */
+
+#ifndef FD_CLOEXEC
+# define FD_CLOEXEC 1
+#endif
 
 /* Fix up the O_* macros.  */
 
@@ -75,6 +80,12 @@ extern void _gl_register_fd (int fd, const char *filename);
 # define O_DIRECT O_DIRECTIO
 #endif
 
+#if !defined O_CLOEXEC && defined O_NOINHERIT
+/* Mingw spells it `O_NOINHERIT'.  Intentionally leave it undefined
+   if not available until gnulib provides a functional replacement.  */
+# define O_CLOEXEC O_NOINHERIT
+#endif
+
 #ifndef O_DIRECT
 # define O_DIRECT 0
 #endif
diff --git a/lib/popen-safer.c b/lib/popen-safer.c
index 2182a2c..1905be5 100644
--- a/lib/popen-safer.c
+++ b/lib/popen-safer.c
@@ -27,9 +27,7 @@
 
 #include "cloexec.h"
 
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define O_CLOEXEC O_NOINHERIT
-#elif !defined O_CLOEXEC
+#ifndef O_CLOEXEC
 # define O_CLOEXEC 0
 #endif
 
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]