]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* src/job.c (child_execute_job): Set pid to -1 on posix_spawn failure.
authorPaul Smith <psmith@gnu.org>
Sat, 24 Aug 2019 21:40:41 +0000 (17:40 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 25 Aug 2019 21:16:40 +0000 (17:16 -0400)
src/job.c

index 1df329ee2dc303d67d0177705e8181d15c5916e5..604b1d1063f1e79b8d9c61934a61795371279576 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -2236,7 +2236,7 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
   int fderr = FD_STDERR;
   pid_t pid;
   int r;
-#if USE_POSIX_SPAWN
+#if defined(USE_POSIX_SPAWN)
   short flags = 0;
   posix_spawnattr_t attr;
   posix_spawn_file_actions_t fa;
@@ -2280,8 +2280,6 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
 
 #else /* use posix_spawn() */
 
-  pid = -1;
-
   if ((r = posix_spawnattr_init (&attr)) != 0)
     goto done;
 
@@ -2338,9 +2336,13 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
  cleanup:
   posix_spawn_file_actions_destroy (&fa);
   posix_spawnattr_destroy (&attr);
-#endif /* have posix_spawn() */
 
  done:
+  if (r != 0)
+    pid = -1;
+
+#endif /* have posix_spawn() */
+
   if (pid < 0)
     OSS (error, NILF, "%s: %s", argv[0], strerror (r));