summaryrefslogtreecommitdiff
path: root/lib/execute.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-12-25 02:15:38 +0100
committerBruno Haible <bruno@clisp.org>2020-12-25 02:18:25 +0100
commit4f766278c569ceebc49f8b8f963acc61cb935af4 (patch)
treed65dcdc9fee7acea98c72d035cb8f018d8ba7ae5 /lib/execute.c
parent1013adf6bf48627f84a9043cf2631ff13d2a452f (diff)
downloadgnulib-4f766278c569ceebc49f8b8f963acc61cb935af4.tar.gz
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.
Diffstat (limited to 'lib/execute.c')
-rw-r--r--lib/execute.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/execute.c b/lib/execute.c
index 4cc779e4ac..24fbbc7b81 100644
--- a/lib/execute.c
+++ b/lib/execute.c
@@ -42,7 +42,20 @@
#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,