Fix handling of closed stdin/stdout/stderr on mingw.
[pspp] / ChangeLog
index c1ab0fb5dbf797a5765b6dec243f60cd48925993..44d91e6ea8311a7bb8c8eb27b4be5d63d315a672 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2009-07-19  Bruno Haible  <bruno@clisp.org>
 
+       Fix handling of closed stdin/stdout/stderr on mingw.
+       * lib/w32spawn.h: Include unistd.h.
+       (dup_noinherit): Return -1 if the old handle is invalid. Allocate new
+       file descriptor with O_NOINHERIT flag.
+       (fd_safer_noinherit): New function, based on fd-safer.c.
+       (dup_safer_noinherit): New function, based on dup-safer.c.
+       (undup_safer_noinherit): New function.
+       * lib/execute.c (execute) [WIN32]: Use dup_safer_noinherit instead of
+       dup_noinherit. Use undup_safer_noinherit instead of dup2 and close.
+       * lib/pipe.c (create_pipe) [WIN32]: Likewise. Use fd_safer_noinherit
+       instead of fd_safer.
+       * tests/test-pipe.c: Include <windows.h>.
+       (child_main) [WIN32]: Test the handle of STDERR_FILENO, not its close() result.
+
+       * tests/test-pipe.c (child_main, parent_main): New functions, extracted
+       from main.
+       (test_pipe): Pass an extra argument for disambiguation.
+       (main): Invoke parent_main or child_main.
+
        * tests/test-pipe.c (test_pipe): Pass slave_process = true argument
        consistently.