>From 4f766278c569ceebc49f8b8f963acc61cb935af4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 25 Dec 2020 02:15:38 +0100 Subject: [PATCH 1/3] 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. --- ChangeLog | 6 ++++++ lib/execute.c | 21 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30be929..afc5829 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-12-24 Bruno Haible + + 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 canonicalize-lgpl: merge proposed libc changes diff --git a/lib/execute.c b/lib/execute.c index 4cc779e..24fbbc7 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, -- 2.7.4