This was previously not handled correctly by newlib.

Signed-off-by: Jeremy Drake <cyg...@jdrake.com>
---
This requires a newlib fix
(https://sourceware.org/pipermail/newlib/2025/021971.html) to pass on
Cygwin.  It passes on Linux.

 winsup/testsuite/winsup.api/posix_spawn/fds.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/winsup/testsuite/winsup.api/posix_spawn/fds.c 
b/winsup/testsuite/winsup.api/posix_spawn/fds.c
index 98ce36ff36..dab96ab33c 100644
--- a/winsup/testsuite/winsup.api/posix_spawn/fds.c
+++ b/winsup/testsuite/winsup.api/posix_spawn/fds.c
@@ -74,6 +74,16 @@ int main (int argc, char **argv)
   exitStatus (status, 0);
   errCode (posix_spawn_file_actions_destroy (&fa));

+  /* test posix_spawn_file_actions_addopen with O_CLOEXEC */
+  errCode (posix_spawn_file_actions_init (&fa));
+  errCode (posix_spawn_file_actions_addopen (&fa, 0, "/dev/zero",
+                                            O_RDONLY|O_CLOEXEC, 0644));
+  childargv[3] = "<ENOENT>";
+  errCode (posix_spawn (&pid, MYSELF, &fa, NULL, childargv, environ));
+  negError (waitpid (pid, &status, 0));
+  exitStatus (status, 0);
+  errCode (posix_spawn_file_actions_destroy (&fa));
+
   /* test posix_spawn_file_actions_adddup2 */
   errCode (posix_spawn_file_actions_init (&fa));
   errCode (posix_spawn_file_actions_adddup2 (&fa, fd, 0));
-- 
2.50.1.windows.1

Reply via email to