]> Savannah Git Hosting - gnulib.git/commitdiff
unistd-h: Make sure O_CLOEXEC is defined.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 16 Feb 2025 20:23:57 +0000 (12:23 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 16 Feb 2025 20:23:57 +0000 (12:23 -0800)
* modules/unistd-h (Depends-on): Add fcntl-h.
* lib/unistd.in.h: Include fcntl.h if inclusion of unistd.h does not
define O_CLOEXEC.
* doc/posix-headers/unistd.texi: Document the platforms that do not
define O_CLOEXEC in unistd.h.

ChangeLog
doc/posix-headers/unistd.texi
lib/unistd.in.h
modules/unistd-h

index 1fa41775dcf19e08183d2e7da4c19709baa1dd7c..de21277abe49d633eb47e9d73fa966c4bddbeb63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-02-16  Collin Funk  <collin.funk1@gmail.com>
+
+       unistd-h: Make sure O_CLOEXEC is defined.
+       * modules/unistd-h (Depends-on): Add fcntl-h.
+       * lib/unistd.in.h: Include fcntl.h if inclusion of unistd.h does not
+       define O_CLOEXEC.
+       * doc/posix-headers/unistd.texi: Document the platforms that do not
+       define O_CLOEXEC in unistd.h.
+
 2025-02-16  Bruno Haible  <bruno@clisp.org>
 
        strncasecmp: Add tests.
index 70c9a87154387674d3440e4d7f144c08f9151fe7..4481bcfc1a6a4f8aed8476d1b9a20242ad3439fc 100644 (file)
@@ -23,6 +23,9 @@ OS/2 EMX, mingw.
 @item
 The @code{_exit} function is not declared in this file on some platforms:
 mingw.
+@item
+This header file does not define @code{O_CLOEXEC} on some platforms:
+glibc 2.41, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, Cygwin 3.5, mingw, MSVC 14.
 
 @item
 Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
index 3f96e10d7e77bbdd0c7738314aa07b93c95b58ee..acabdf8c6893531b289cb9613848c341d0b84dd2 100644 (file)
 # include <stdio.h>
 #endif
 
+/* FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Solaris 11.4, and glibc 2.41
+   do not define O_CLOEXEC in <unistd.h>.  */
 /* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
    <unistd.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
-    && (defined __CYGWIN__ || defined __ANDROID__) \
-    && ! defined __GLIBC__
+#if ! defined O_CLOEXEC \
+    || ((@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
+         && (defined __CYGWIN__ || defined __ANDROID__) \
+         && ! defined __GLIBC__)
 # include <fcntl.h>
 #endif
 
index af7fda5944c7a2bb268f6223c02685bf6c8785a8..1a7376efdb72841b7c67d9298a6d9d2a699bf475 100644 (file)
@@ -15,6 +15,7 @@ include_next
 snippet/arg-nonnull
 snippet/c++defs
 snippet/warn-on-use
+fcntl-h
 ssize_t
 stddef-h
 sys_types-h