--- /SourceCache/gnumake/gnumake-121/make/job.c 2007-01-29 17:28:17.000000000 -0800 +++ ./job.c 2008-10-15 18:53:33.000000000 -0700 @@ -29,6 +29,9 @@ Foundation, Inc., 51 Franklin St, Fifth #include <string.h> +#if USE_POSIX_SPAWN +#include <spawn.h> +#endif /* Default shell to use. */ #ifdef WINDOWS32 #include <windows.h> @@ -1295,6 +1298,42 @@ start_job_command (struct child *child) #else /* !__EMX__ */ +#if USE_POSIX_SPAWN + posix_spawn_file_actions_t file_actions; + posix_spawnattr_t attr; + sigset_t nosigs, allsigs; + int rc; + struct stat stat; + short spawn_flags = 0; + + posix_spawn_file_actions_init(&file_actions); + if (!(flags & COMMANDS_RECURSE)) { + if (job_fds[0] >= 0 && fstat(job_fds[0], &stat)) + posix_spawn_file_actions_addclose(&file_actions, job_fds[0]); + if (job_fds[1] >= 0 && fstat(job_fds[1], &stat)) + posix_spawn_file_actions_addclose(&file_actions, job_fds[1]); + } + if (job_rfd >= 0 && fstat(job_rfd, &stat)) + posix_spawn_file_actions_addclose(&file_actions, job_rfd); + if (!child->good_stdin && fstat(bad_stdin, &stat)) + posix_spawn_file_actions_adddup2(&file_actions, bad_stdin, 0); + posix_spawnattr_init(&attr); + sigemptyset(&nosigs); + sigfillset(&allsigs); + posix_spawnattr_setsigmask(&attr, &nosigs); + posix_spawnattr_setsigdefault(&attr, &allsigs); + posix_spawnattr_getflags(&attr, &spawn_flags); + spawn_flags |= POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK; + posix_spawnattr_setflags(&attr, spawn_flags); + rc = posix_spawnp(&child->pid, argv[0], &file_actions, &attr, argv, child->environment); + environ = parent_environ; + posix_spawnattr_destroy(&attr); + posix_spawn_file_actions_destroy(&file_actions); + if (rc) { + error (NILF, _("%s: %s"), argv[0], strerror(rc)); + rc = posix_spawnp(&child->pid, "/usr/bin/false", NULL, NULL, NULL, NULL); + } +#else /* !USE_POSIX_SPAWN */ child->pid = vfork (); environ = parent_environ; /* Restore value child may have clobbered. */ if (child->pid == 0) @@ -1322,6 +1361,7 @@ start_job_command (struct child *child) perror_with_name ("vfork", ""); goto error; } +# endif /* !USE_POSIX_SPAWN */ # endif /* !__EMX__ */ #endif /* !VMS */ } diff -up /SourceCache/gnumake/gnumake-121/make/main.c ./main.c --- /SourceCache/gnumake/gnumake-121/make/main.c 2008-06-19 19:55:59.000000000 -0700 +++ ./main.c 2008-08-25 22:09:52.000000000 -0700 @@ -2141,8 +2141,10 @@ main (int argc, char **argv, char **envp fflush (stderr); /* Close the dup'd jobserver pipe if we opened one. */ - if (job_rfd >= 0) + if (job_rfd >= 0) { close (job_rfd); + job_rfd = -1; + } #ifdef _AMIGA exec_command (nargv); @@ -3108,7 +3110,7 @@ clean_jobserver (int status) /* Close the write side, so the read() won't hang. */ close (job_fds[1]); - + job_fds[1] = -1; while (read (job_fds[0], &token, 1) == 1) ++tcnt; @@ -3118,6 +3120,7 @@ clean_jobserver (int status) tcnt, master_job_slots); close (job_fds[0]); + job_fds[0] = -1; } }