summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2018-08-04 11:13:57 -0400
committerPaul Smith <psmith@gnu.org>2018-08-04 12:37:19 -0400
commita370268739bd6825d88109c7707e816eee4d3f33 (patch)
tree631f0ec316eb5efa8b97fc07e3fe0305e318f5c6
parent1129df27b8fb3d62f68435bd3aabc86cd2808382 (diff)
downloadmake-git-a370268739bd6825d88109c7707e816eee4d3f33.tar.gz
* configure.ac: Add --disable-posix-spawn option
* maintMakefile: Add a test for the option * src/job.c: Change HAVE_* preprocessor checks to USE_POSIX_SPAWN
-rw-r--r--configure.ac22
-rw-r--r--maintMakefile1
-rw-r--r--src/job.c13
3 files changed, 29 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 6155db7c..31a00a65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -357,6 +357,22 @@ AS_IF([test "$ac_cv_func_lstat" = yes && test "$ac_cv_func_readlink" = yes],
[Define to 1 to enable symbolic link timestamp checking.])
])
+# Use posix_spawn if we have support and the user didn't disable it
+
+AC_ARG_ENABLE([posix-spawn],
+ AC_HELP_STRING([--disable-posix-spawn],
+ [disable support for posix_spawn()]),
+ [make_cv_posix_spawn="$enableval" user_posix_spawn="$enableval"],
+ [make_cv_posix_spawn="yes"])
+
+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/],
+ [*/no/*], [make_cv_posix_spawn=no],
+ [AC_DEFINE(USE_POSIX_SPAWN, 1, [Define to 1 to use posix_spawn().])
+ ])
+
# Find the SCCS commands, so we can include them in our default rules.
AC_CACHE_CHECK([for location of SCCS get command], [make_cv_path_sccs_get], [
@@ -498,6 +514,12 @@ AS_IF([test "x$make_cv_load" = xno && test "x$user_load" = xyes],
echo
])
+AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
+[ echo
+ echo "WARNING: posix_spawn() is not supported on this system."
+ echo
+])
+
# Specify what files are to be created.
AC_CONFIG_FILES([Makefile lib/Makefile po/Makefile.in doc/Makefile \
tests/config-flags.pm])
diff --git a/maintMakefile b/maintMakefile
index cea4db14..05578e6f 100644
--- a/maintMakefile
+++ b/maintMakefile
@@ -240,6 +240,7 @@ CONFIG_CHECKS := \
checkcfg.--disable-job-server \
checkcfg.--disable-load \
checkcfg.--without-guile \
+ checkcfg.--disable-posix-spawn \
checkcfg.make_cv_sys_gnu_glob^no \
checkcfg.ac_cv_func_getloadavg^no+ac_cv_have_decl_getloadavg^no+gl_cv_have_raw_decl_getloadavg^no+ac_cv_lib_util_getloadavg^no+ac_cv_lib_getloadavg_getloadavg^no \
checkcfg.CPPFLAGS^-DNO_OUTPUT_SYNC \
diff --git a/src/job.c b/src/job.c
index 099934b1..afe742e2 100644
--- a/src/job.c
+++ b/src/job.c
@@ -137,9 +137,9 @@ extern int wait3 ();
# endif /* Have wait3. */
#endif /* Have waitpid. */
-#ifdef HAVE_SPAWN_H
+#ifdef USE_POSIX_SPAWN
# include <spawn.h>
-#endif /* have spawn.h */
+#endif
#if !defined (wait) && !defined (POSIX)
int wait ();
@@ -2234,13 +2234,13 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
const int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
int fdout = FD_STDOUT;
int fderr = FD_STDERR;
- int r;
pid_t pid;
-#if HAVE_POSIX_SPAWN
+ int r;
+#if USE_POSIX_SPAWN
short flags = 0;
posix_spawnattr_t attr;
posix_spawn_file_actions_t fa;
-#endif /* have posix_spawn() */
+#endif
/* Divert child output if we want to capture it. */
if (out && out->syncout)
@@ -2251,8 +2251,7 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
fderr = out->err;
}
-#if ! HAVE_POSIX_SPAWN
- /* does not have posix_spawn() */
+#if !defined(USE_POSIX_SPAWN)
pid = vfork();
if (pid != 0)