]> Savannah Git Hosting - gnulib.git/commitdiff
execute: Use posix_spawn by default on native Windows.
authorBruno Haible <bruno@clisp.org>
Fri, 25 Dec 2020 01:15:38 +0000 (02:15 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 25 Dec 2020 01:18:25 +0000 (02:18 +0100)
* lib/execute.c (EXECUTE_IMPL_AVOID_POSIX_SPAWN): New macro.
(execute): Use it to decide among the two possible implementations.

ChangeLog
lib/execute.c

index 30be929b52edc43a687162d0061a36d8becdfcc9..afc5829ebb372eccdcae3d6bbe83758f7b138cc7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-24  Bruno Haible  <bruno@clisp.org>
+
+       execute: Use posix_spawn by default on native Windows.
+       * lib/execute.c (EXECUTE_IMPL_AVOID_POSIX_SPAWN): New macro.
+       (execute): Use it to decide among the two possible implementations.
+
 2020-12-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        canonicalize-lgpl: merge proposed libc changes
index 4cc779e4acc832d75260dd03697a768ae784ae9c..24fbbc7b81cee4db5fda8def9bb48915679cd816 100644 (file)
 
 #define _(str) gettext (str)
 
-#if defined _WIN32 && ! defined __CYGWIN__
+
+/* Choice of implementation for native Windows.
+   - Define to 0 to use the posix_spawn facility (modules 'posix_spawn' and
+     'posix_spawnp'), that is based on the module 'windows-spawn'.
+   - Define to 1 to use the older code, that uses the module 'windows-spawn'
+     directly.
+   You can set this macro from a Makefile or at configure time, from the
+   CPPFLAGS.  */
+#ifndef EXECUTE_IMPL_AVOID_POSIX_SPAWN
+# define EXECUTE_IMPL_AVOID_POSIX_SPAWN 0
+#endif
+
+
+#if (defined _WIN32 && !defined __CYGWIN__) && EXECUTE_IMPL_AVOID_POSIX_SPAWN
 
 /* Native Windows API.  */
 # if GNULIB_MSVC_NOTHROW
@@ -61,7 +74,7 @@
 #endif
 
 
-#if defined EINTR && (defined _WIN32 && ! defined __CYGWIN__)
+#if defined EINTR && (defined _WIN32 && !defined __CYGWIN__) && EXECUTE_IMPL_AVOID_POSIX_SPAWN
 
 /* EINTR handling for close(), open().
    These functions can return -1/EINTR even though we don't have any
@@ -157,7 +170,7 @@ execute (const char *progname,
         }
     }
 
-#if defined _WIN32 && ! defined __CYGWIN__
+#if (defined _WIN32 && !defined __CYGWIN__) && EXECUTE_IMPL_AVOID_POSIX_SPAWN
 
   /* Native Windows API.  */
 
@@ -281,6 +294,7 @@ execute (const char *progname,
           || (directory != NULL
               && (err = posix_spawn_file_actions_addchdir (&actions,
                                                            directory)))
+# if !(defined _WIN32 && !defined __CYGWIN__)
           || (slave_process
               && ((err = posix_spawnattr_init (&attrs)) != 0
                   || (attrs_allocated = true,
@@ -290,6 +304,7 @@ execute (const char *progname,
                       || (err = posix_spawnattr_setflags (&attrs,
                                                         POSIX_SPAWN_SETSIGMASK))
                          != 0)))
+# endif
           || (err = (directory != NULL
                      ? posix_spawn (&child, prog_path, &actions,
                                     attrs_allocated ? &attrs : NULL,