In a testdir of module 'posix_spawn_file_actions_addclose', I see this test
failure on NetBSD 10.0:
FAIL: test-posix_spawn_file_actions_addclose
============================================
../../gnulib-tests/test-posix_spawn_file_actions_addclose.c:63: assertion
'posix_spawn_file_actions_addclose (&actions, bad_fd) == EBADF' failed
FAIL test-posix_spawn_file_actions_addclose (exit status: 134)
The cause is that
* NetBSD does not reject out-of-range fd arguments, see in the
NetBSD source code, at
src/lib/libc/gen/posix_spawn_fileactions.c, function
posix_spawn_file_actions_addclose.
* The configure test does not mark
posix_spawn_file_actions_addclose as broken.
This patch fixes it.
2025-10-28 Bruno Haible <[email protected]>
posix_spawn_file_actions_addclose: Fix test failure on NetBSD 10.0.
* m4/posix_spawn.m4 (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE): Test
also against the NetBSD bug.
* doc/posix-functions/posix_spawn_file_actions_addclose.texi: Document
the NetBSD bug.
diff --git a/doc/posix-functions/posix_spawn_file_actions_addclose.texi
b/doc/posix-functions/posix_spawn_file_actions_addclose.texi
index f5dd407042..12ac6e9514 100644
--- a/doc/posix-functions/posix_spawn_file_actions_addclose.texi
+++ b/doc/posix-functions/posix_spawn_file_actions_addclose.texi
@@ -15,6 +15,9 @@
@item
This function does not reject a negative file descriptor on some platforms:
musl libc.
+@item
+This function does not reject an out-of-range file descriptor on some
platforms:
+NetBSD.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
index a170ced5a5..4c1f755f37 100644
--- a/m4/posix_spawn.m4
+++ b/m4/posix_spawn.m4
@@ -1,5 +1,5 @@
# posix_spawn.m4
-# serial 25
+# serial 26
dnl Copyright (C) 2008-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -571,6 +571,8 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]
else
dnl On musl libc, posix_spawn_file_actions_addclose succeeds even if the fd
dnl argument is negative.
+ dnl On NetBSD 10.0, posix_spawn_file_actions_addclose succeeds even if the
+ dnl fd argument is out of range.
AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works],
[gl_cv_func_posix_spawn_file_actions_addclose_works],
[AC_RUN_IFELSE(
@@ -583,13 +585,16 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE]
return 1;
if (posix_spawn_file_actions_addclose (&actions, -5) == 0)
return 2;
+ if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0)
+ return 3;
return 0;
}]])],
[gl_cv_func_posix_spawn_file_actions_addclose_works=yes],
[gl_cv_func_posix_spawn_file_actions_addclose_works=no],
- [# Guess no on musl libc and Solaris, yes otherwise.
+ [# Guess no on musl libc and NetBSD and Solaris, yes otherwise.
case "$host_os" in
*-musl* | midipix*)
gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
+ netbsd*)
gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
solaris*)
gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
# Guess no on native Windows.
mingw* | windows*)
gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;