* lib/execute.c: Include <sys/types.h>, <sys/wait.h>.
(execute): Recognize the case where the exit code indicates a signalled
child process.
* tests/test-execute-main.c (main): Update expected test result.
* modules/execute (Depends-on): Add sys_wait.
+2020-12-24 Bruno Haible <bruno@clisp.org>
+
+ execute: Treat signalled processes like wait-process does.
+ * lib/execute.c: Include <sys/types.h>, <sys/wait.h>.
+ (execute): Recognize the case where the exit code indicates a signalled
+ child process.
+ * tests/test-execute-main.c (main): Update expected test result.
+ * modules/execute (Depends-on): Add sys_wait.
+
2020-12-24 Bruno Haible <bruno@clisp.org>
windows-spawn: Improve errno upon failure on native Windows.
#include <signal.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
#include "canonicalize.h"
#include "error.h"
#include "fatal-signal.h"
free (argv_mem_to_free);
free (prog_path_to_free);
+ /* Treat failure and signalled child processes like wait_subprocess()
+ does. */
if (termsigp != NULL)
*termsigp = 0;
if (exitcode == -1)
goto fail_with_saved_errno;
+ if (WIFSIGNALED (exitcode))
+ {
+ if (termsigp != NULL)
+ *termsigp = WTERMSIG (exitcode);
+ saved_errno = 0;
+ goto fail_with_saved_errno;
+ }
+
return exitcode;
#else
posix_spawnattr_destroy
stdbool
stdlib
+sys_wait
unistd
wait-process
windows-spawn
int termsig = 0xDEADBEEF;
int ret = execute (progname, prog_argv[0], prog_argv, NULL,
false, false, false, false, true, false, &termsig);
+ ASSERT (ret == 127);
#if defined _WIN32 && !defined __CYGWIN__
- ASSERT (ret == 3);
- ASSERT (termsig == 0);
+ ASSERT (termsig == SIGTERM); /* dummy, from WTERMSIG in <sys/wait.h> */
#else
- ASSERT (ret == 127);
ASSERT (termsig == SIGINT);
#endif
}