bug-gnulib
[Top][All Lists]
Advanced

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

posix_spawn_file_actions_addclose: Relax configure test


From: Bruno Haible
Subject: posix_spawn_file_actions_addclose: Relax configure test
Date: Mon, 25 Jan 2021 10:04:23 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; )

Our posix_spawn_file_actions_addclose configure test is too strong:
POSIX [1] requires posix_spawn_file_actions_addopen, but not
posix_spawn_file_actions_addclose, to reject too large file descriptors.

[1] 
https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_actions_addclose.html


2021-01-25  Bruno Haible  <bruno@clisp.org>

        posix_spawn_file_actions_addclose: Relax configure test.
        * m4/posix_spawn.m4 (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE): Test a
        negative file descriptor, not an out-of-range file descriptor.
        * tests/test-posix_spawn_file_actions_addclose.c (main): Add comment.
        * doc/posix-functions/posix_spawn_file_actions_addclose.texi: Update.

diff --git a/doc/posix-functions/posix_spawn_file_actions_addclose.texi 
b/doc/posix-functions/posix_spawn_file_actions_addclose.texi
index 6a1ba1b..db5bcfd 100644
--- a/doc/posix-functions/posix_spawn_file_actions_addclose.texi
+++ b/doc/posix-functions/posix_spawn_file_actions_addclose.texi
@@ -12,8 +12,8 @@ Portability problems fixed by Gnulib:
 This function is missing on some platforms:
 FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 
6.5, Solaris 9, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1.
 @item
-This function does not reject a too large file descriptor on some platforms:
-musl libc, Solaris 11.4.
+This function does not reject a negative file descriptor on some platforms:
+musl libc.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
index 787336d..da87130 100644
--- a/m4/posix_spawn.m4
+++ b/m4/posix_spawn.m4
@@ -1,4 +1,4 @@
-# posix_spawn.m4 serial 19
+# posix_spawn.m4 serial 20
 dnl Copyright (C) 2008-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -552,8 +552,8 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE],
   if test $REPLACE_POSIX_SPAWN = 1; then
     REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1
   else
-    dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addclose
-    dnl succeeds even if the fd argument is out of range.
+    dnl On musl libc, posix_spawn_file_actions_addclose succeeds even if the fd
+    dnl argument is negative.
     AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works],
       [gl_cv_func_posix_spawn_file_actions_addclose_works],
       [AC_RUN_IFELSE(
@@ -564,7 +564,7 @@ int main ()
   posix_spawn_file_actions_t actions;
   if (posix_spawn_file_actions_init (&actions) != 0)
     return 1;
-  if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0)
+  if (posix_spawn_file_actions_addclose (&actions, -5) == 0)
     return 2;
   return 0;
 }]])],
diff --git a/tests/test-posix_spawn_file_actions_addclose.c 
b/tests/test-posix_spawn_file_actions_addclose.c
index 3aca333..2c910ea 100644
--- a/tests/test-posix_spawn_file_actions_addclose.c
+++ b/tests/test-posix_spawn_file_actions_addclose.c
@@ -54,6 +54,8 @@ main (void)
     errno = 0;
     ASSERT (posix_spawn_file_actions_addclose (&actions, -1) == EBADF);
   }
+  /* This behaviour is not mandated by POSIX, but happens to pass on all
+     platforms.  */
   {
     int bad_fd = big_fd ();
     errno = 0;




reply via email to

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