diff options
author | Paul Smith <psmith@gnu.org> | 2019-12-27 01:27:09 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2019-12-27 01:37:17 -0500 |
commit | e64674b718600bd4fad0b5ac1cc37eb89fba5ef7 (patch) | |
tree | 7bb82458a418fdf9b3af48954b76e0bbdddc29d4 /configure.ac | |
parent | 564fb212a727a6b6773f454d192a7e02de62d2ef (diff) | |
download | make-git-e64674b718600bd4fad0b5ac1cc37eb89fba5ef7.tar.gz |
[SV 57022] Avoid posix_spawn which fails asynchronously
Avoid using posix_spawn implementations that fail asynchronously when
the spawned program can't be invoked: this means instead of getting
an error such as "No such file or directory" we get just "Exit 127".
Original implementation of the configure.ac macro provided by
Martin Dorey <martin.dorey@hds.com>
Original implementation of the regression tests provided by
Dmitry Goncharov <dgoncharov@users.sf.net>
* configure.ac: Test whether posix_spawn fails asynchronously. In a
cross-compilation environment, assume that it does not. If we detect
that it does, fall back to fork/exec.
* tests/scripts/features/exec: Add regression tests for different
shebang invocation methods.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index af58c1b4..5daff11e 100644 --- a/configure.ac +++ b/configure.ac @@ -371,7 +371,28 @@ AC_ARG_ENABLE([posix-spawn], AS_CASE([/$ac_cv_header_spawn/$ac_cv_func_posix_spawn/], [*/no/*], [make_cv_posix_spawn=no]) -AS_CASE([/$make_cv_posix_spawn/$user_posix_spawn/], +AS_IF([test "$make_cv_posix_spawn" = yes], + AC_CACHE_CHECK([for posix_spawn that fails synchronously], + [make_cv_synchronous_posix_spawn], + [make_cv_synchronous_posix_spawn=no + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include <spawn.h> + #include <string.h> + + extern char **environ; + + int main() { + char* path = strdup("./non-existent"); + char *argv[[2]]; + argv[[0]] = path; + argv[[1]] = 0; + return posix_spawn(0, path, 0, 0, argv, environ); + }]])], + [make_cv_synchronous_posix_spawn=no], + [make_cv_synchronous_posix_spawn=yes], + [make_cv_synchronous_posix_spawn="no (cross-compiling)"])])) + +AS_CASE([/$user_posix_spawn/$make_cv_posix_spawn/$make_cv_synchronous_posix_spawn/], [*/no/*], [make_cv_posix_spawn=no], [AC_DEFINE(USE_POSIX_SPAWN, 1, [Define to 1 to use posix_spawn().]) ]) |