wait[pid]() is called in several places. If we encounter an error and run the .ERROR target, we may reap a pid which jobs is waiting for. Ensure that we cleanup so that make isn't left waiting for an already deceased child.diff -r1.79 -r1.80 src/usr.bin/make/compat.c
(sjg)
--- src/usr.bin/make/compat.c 2010/06/03 15:40:15 1.79
+++ src/usr.bin/make/compat.c 2010/08/07 06:44:08 1.80
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compat.c,v 1.79 2010/06/03 15:40:15 sjg Exp $ */ | 1 | /* $NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -60,34 +60,34 @@ | @@ -60,34 +60,34 @@ | |||
60 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 60 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
61 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 61 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
69 | * SUCH DAMAGE. | 69 | * SUCH DAMAGE. | |
70 | */ | 70 | */ | |
71 | 71 | |||
72 | #ifndef MAKE_NATIVE | 72 | #ifndef MAKE_NATIVE | |
73 | static char rcsid[] = "$NetBSD: compat.c,v 1.79 2010/06/03 15:40:15 sjg Exp $"; | 73 | static char rcsid[] = "$NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $"; | |
74 | #else | 74 | #else | |
75 | #include <sys/cdefs.h> | 75 | #include <sys/cdefs.h> | |
76 | #ifndef lint | 76 | #ifndef lint | |
77 | #if 0 | 77 | #if 0 | |
78 | static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; | 78 | static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; | |
79 | #else | 79 | #else | |
80 | __RCSID("$NetBSD: compat.c,v 1.79 2010/06/03 15:40:15 sjg Exp $"); | 80 | __RCSID("$NetBSD: compat.c,v 1.80 2010/08/07 06:44:08 sjg Exp $"); | |
81 | #endif | 81 | #endif | |
82 | #endif /* not lint */ | 82 | #endif /* not lint */ | |
83 | #endif | 83 | #endif | |
84 | 84 | |||
85 | /*- | 85 | /*- | |
86 | * compat.c -- | 86 | * compat.c -- | |
87 | * The routines in this file implement the full-compatibility | 87 | * The routines in this file implement the full-compatibility | |
88 | * mode of PMake. Most of the special functionality of PMake | 88 | * mode of PMake. Most of the special functionality of PMake | |
89 | * is available in this mode. Things not supported: | 89 | * is available in this mode. Things not supported: | |
90 | * - different shells. | 90 | * - different shells. | |
91 | * - friendly variable substitution. | 91 | * - friendly variable substitution. | |
92 | * | 92 | * | |
93 | * Interface: | 93 | * Interface: | |
@@ -371,26 +371,28 @@ again: | @@ -371,26 +371,28 @@ again: | |||
371 | } | 371 | } | |
372 | if (mav) | 372 | if (mav) | |
373 | free(mav); | 373 | free(mav); | |
374 | if (bp) | 374 | if (bp) | |
375 | free(bp); | 375 | free(bp); | |
376 | Lst_Replace(cmdNode, NULL); | 376 | Lst_Replace(cmdNode, NULL); | |
377 | 377 | |||
378 | /* | 378 | /* | |
379 | * The child is off and running. Now all we can do is wait... | 379 | * The child is off and running. Now all we can do is wait... | |
380 | */ | 380 | */ | |
381 | while (1) { | 381 | while (1) { | |
382 | 382 | |||
383 | while ((retstat = wait(&reason)) != cpid) { | 383 | while ((retstat = wait(&reason)) != cpid) { | |
384 | if (retstat > 0) | |||
385 | JobReapChild(retstat, reason, FALSE); /* not ours? */ | |||
384 | if (retstat == -1 && errno != EINTR) { | 386 | if (retstat == -1 && errno != EINTR) { | |
385 | break; | 387 | break; | |
386 | } | 388 | } | |
387 | } | 389 | } | |
388 | 390 | |||
389 | if (retstat > -1) { | 391 | if (retstat > -1) { | |
390 | if (WIFSTOPPED(reason)) { | 392 | if (WIFSTOPPED(reason)) { | |
391 | status = WSTOPSIG(reason); /* stopped */ | 393 | status = WSTOPSIG(reason); /* stopped */ | |
392 | } else if (WIFEXITED(reason)) { | 394 | } else if (WIFEXITED(reason)) { | |
393 | status = WEXITSTATUS(reason); /* exited */ | 395 | status = WEXITSTATUS(reason); /* exited */ | |
394 | if (status != 0) { | 396 | if (status != 0) { | |
395 | if (DEBUG(ERROR)) { | 397 | if (DEBUG(ERROR)) { | |
396 | fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ", | 398 | fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ", |
--- src/usr.bin/make/job.c 2010/07/20 16:39:27 1.152
+++ src/usr.bin/make/job.c 2010/08/07 06:44:08 1.153
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: job.c,v 1.152 2010/07/20 16:39:27 christos Exp $ */ | 1 | /* $NetBSD: job.c,v 1.153 2010/08/07 06:44:08 sjg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -60,34 +60,34 @@ | @@ -60,34 +60,34 @@ | |||
60 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 60 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
61 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 61 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 62 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 63 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 64 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 65 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 66 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 67 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 68 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
69 | * SUCH DAMAGE. | 69 | * SUCH DAMAGE. | |
70 | */ | 70 | */ | |
71 | 71 | |||
72 | #ifndef MAKE_NATIVE | 72 | #ifndef MAKE_NATIVE | |
73 | static char rcsid[] = "$NetBSD: job.c,v 1.152 2010/07/20 16:39:27 christos Exp $"; | 73 | static char rcsid[] = "$NetBSD: job.c,v 1.153 2010/08/07 06:44:08 sjg Exp $"; | |
74 | #else | 74 | #else | |
75 | #include <sys/cdefs.h> | 75 | #include <sys/cdefs.h> | |
76 | #ifndef lint | 76 | #ifndef lint | |
77 | #if 0 | 77 | #if 0 | |
78 | static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; | 78 | static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; | |
79 | #else | 79 | #else | |
80 | __RCSID("$NetBSD: job.c,v 1.152 2010/07/20 16:39:27 christos Exp $"); | 80 | __RCSID("$NetBSD: job.c,v 1.153 2010/08/07 06:44:08 sjg Exp $"); | |
81 | #endif | 81 | #endif | |
82 | #endif /* not lint */ | 82 | #endif /* not lint */ | |
83 | #endif | 83 | #endif | |
84 | 84 | |||
85 | /*- | 85 | /*- | |
86 | * job.c -- | 86 | * job.c -- | |
87 | * handle the creation etc. of our child processes. | 87 | * handle the creation etc. of our child processes. | |
88 | * | 88 | * | |
89 | * Interface: | 89 | * Interface: | |
90 | * Job_Make Start the creation of the given target. | 90 | * Job_Make Start the creation of the given target. | |
91 | * | 91 | * | |
92 | * Job_CatchChildren Check for and handle the termination of any | 92 | * Job_CatchChildren Check for and handle the termination of any | |
93 | * children. This must be called reasonably | 93 | * children. This must be called reasonably | |
@@ -334,27 +334,27 @@ static Job childExitJob; /* child exit p | @@ -334,27 +334,27 @@ static Job childExitJob; /* child exit p | |||
334 | #define TARG_FMT "%s %s ---\n" /* Default format */ | 334 | #define TARG_FMT "%s %s ---\n" /* Default format */ | |
335 | #define MESSAGE(fp, gn) \ | 335 | #define MESSAGE(fp, gn) \ | |
336 | (void)fprintf(fp, targFmt, targPrefix, gn->name) | 336 | (void)fprintf(fp, targFmt, targPrefix, gn->name) | |
337 | 337 | |||
338 | static sigset_t caught_signals; /* Set of signals we handle */ | 338 | static sigset_t caught_signals; /* Set of signals we handle */ | |
339 | #if defined(SYSV) | 339 | #if defined(SYSV) | |
340 | #define KILLPG(pid, sig) kill(-(pid), (sig)) | 340 | #define KILLPG(pid, sig) kill(-(pid), (sig)) | |
341 | #else | 341 | #else | |
342 | #define KILLPG(pid, sig) killpg((pid), (sig)) | 342 | #define KILLPG(pid, sig) killpg((pid), (sig)) | |
343 | #endif | 343 | #endif | |
344 | 344 | |||
345 | static void JobChildSig(int); | 345 | static void JobChildSig(int); | |
346 | static void JobContinueSig(int); | 346 | static void JobContinueSig(int); | |
347 | static Job *JobFindPid(int, int); | 347 | static Job *JobFindPid(int, int, Boolean); | |
348 | static int JobPrintCommand(void *, void *); | 348 | static int JobPrintCommand(void *, void *); | |
349 | static int JobSaveCommand(void *, void *); | 349 | static int JobSaveCommand(void *, void *); | |
350 | static void JobClose(Job *); | 350 | static void JobClose(Job *); | |
351 | static void JobExec(Job *, char **); | 351 | static void JobExec(Job *, char **); | |
352 | static void JobMakeArgv(Job *, char **); | 352 | static void JobMakeArgv(Job *, char **); | |
353 | static int JobStart(GNode *, int); | 353 | static int JobStart(GNode *, int); | |
354 | static char *JobOutput(Job *, char *, char *, int); | 354 | static char *JobOutput(Job *, char *, char *, int); | |
355 | static void JobDoOutput(Job *, Boolean); | 355 | static void JobDoOutput(Job *, Boolean); | |
356 | static Shell *JobMatchShell(const char *); | 356 | static Shell *JobMatchShell(const char *); | |
357 | static void JobInterrupt(int, int); | 357 | static void JobInterrupt(int, int); | |
358 | static void JobRestartJobs(void); | 358 | static void JobRestartJobs(void); | |
359 | static void JobTokenAdd(void); | 359 | static void JobTokenAdd(void); | |
360 | static void JobSigLock(sigset_t *); | 360 | static void JobSigLock(sigset_t *); | |
@@ -606,35 +606,35 @@ JobPassSig_suspend(int signo) | @@ -606,35 +606,35 @@ JobPassSig_suspend(int signo) | |||
606 | * | 606 | * | |
607 | * Input: | 607 | * Input: | |
608 | * job job to examine | 608 | * job job to examine | |
609 | * pid process id desired | 609 | * pid process id desired | |
610 | * | 610 | * | |
611 | * Results: | 611 | * Results: | |
612 | * Job with matching pid | 612 | * Job with matching pid | |
613 | * | 613 | * | |
614 | * Side Effects: | 614 | * Side Effects: | |
615 | * None | 615 | * None | |
616 | *----------------------------------------------------------------------- | 616 | *----------------------------------------------------------------------- | |
617 | */ | 617 | */ | |
618 | static Job * | 618 | static Job * | |
619 | JobFindPid(int pid, int status) | 619 | JobFindPid(int pid, int status, Boolean isJobs) | |
620 | { | 620 | { | |
621 | Job *job; | 621 | Job *job; | |
622 | 622 | |||
623 | for (job = job_table; job < job_table_end; job++) { | 623 | for (job = job_table; job < job_table_end; job++) { | |
624 | if ((job->job_state == status) && job->pid == pid) | 624 | if ((job->job_state == status) && job->pid == pid) | |
625 | return job; | 625 | return job; | |
626 | } | 626 | } | |
627 | if (DEBUG(JOB)) | 627 | if (DEBUG(JOB) && isJobs) | |
628 | job_table_dump("no pid"); | 628 | job_table_dump("no pid"); | |
629 | return NULL; | 629 | return NULL; | |
630 | } | 630 | } | |
631 | 631 | |||
632 | /*- | 632 | /*- | |
633 | *----------------------------------------------------------------------- | 633 | *----------------------------------------------------------------------- | |
634 | * JobPrintCommand -- | 634 | * JobPrintCommand -- | |
635 | * Put out another command for the given job. If the command starts | 635 | * Put out another command for the given job. If the command starts | |
636 | * with an @ or a - we process it specially. In the former case, | 636 | * with an @ or a - we process it specially. In the former case, | |
637 | * so long as the -s and -n flags weren't given to make, we stick | 637 | * so long as the -s and -n flags weren't given to make, we stick | |
638 | * a shell-specific echoOff command in the script. In the latter, | 638 | * a shell-specific echoOff command in the script. In the latter, | |
639 | * we ignore errors for the entire job, unless the shell has error | 639 | * we ignore errors for the entire job, unless the shell has error | |
640 | * control. | 640 | * control. | |
@@ -1917,75 +1917,93 @@ JobRun(GNode *targ) | @@ -1917,75 +1917,93 @@ JobRun(GNode *targ) | |||
1917 | * | 1917 | * | |
1918 | * Notes: | 1918 | * Notes: | |
1919 | * We do waits, blocking or not, according to the wisdom of our | 1919 | * We do waits, blocking or not, according to the wisdom of our | |
1920 | * caller, until there are no more children to report. For each | 1920 | * caller, until there are no more children to report. For each | |
1921 | * job, call JobFinish to finish things off. | 1921 | * job, call JobFinish to finish things off. | |
1922 | * | 1922 | * | |
1923 | *----------------------------------------------------------------------- | 1923 | *----------------------------------------------------------------------- | |
1924 | */ | 1924 | */ | |
1925 | 1925 | |||
1926 | void | 1926 | void | |
1927 | Job_CatchChildren(void) | 1927 | Job_CatchChildren(void) | |
1928 | { | 1928 | { | |
1929 | int pid; /* pid of dead child */ | 1929 | int pid; /* pid of dead child */ | |
1930 | Job *job; /* job descriptor for dead child */ | |||
1931 | int status; /* Exit/termination status */ | 1930 | int status; /* Exit/termination status */ | |
1932 | 1931 | |||
1933 | /* | 1932 | /* | |
1934 | * Don't even bother if we know there's no one around. | 1933 | * Don't even bother if we know there's no one around. | |
1935 | */ | 1934 | */ | |
1936 | if (jobTokensRunning == 0) | 1935 | if (jobTokensRunning == 0) | |
1937 | return; | 1936 | return; | |
1938 | 1937 | |||
1939 | while ((pid = waitpid((pid_t) -1, &status, WNOHANG | WUNTRACED)) > 0) { | 1938 | while ((pid = waitpid((pid_t) -1, &status, WNOHANG | WUNTRACED)) > 0) { | |
1940 | if (DEBUG(JOB)) { | 1939 | if (DEBUG(JOB)) { | |
1941 | (void)fprintf(debug_file, "Process %d exited/stopped status %x.\n", pid, | 1940 | (void)fprintf(debug_file, "Process %d exited/stopped status %x.\n", pid, | |
1942 | status); | 1941 | status); | |
1943 | } | 1942 | } | |
1943 | JobReapChild(pid, status, TRUE); | |||
1944 | } | |||
1945 | } | |||
1946 | ||||
1947 | /* | |||
1948 | * It is possible that wait[pid]() was called from elsewhere, | |||
1949 | * this lets us reap jobs regardless. | |||
1950 | */ | |||
1951 | void | |||
1952 | JobReapChild(pid_t pid, int status, Boolean isJobs) | |||
1953 | { | |||
1954 | Job *job; /* job descriptor for dead child */ | |||
1955 | ||||
1956 | /* | |||
1957 | * Don't even bother if we know there's no one around. | |||
1958 | */ | |||
1959 | if (jobTokensRunning == 0) | |||
1960 | return; | |||
1944 | 1961 | |||
1945 | job = JobFindPid(pid, JOB_ST_RUNNING); | 1962 | job = JobFindPid(pid, JOB_ST_RUNNING, isJobs); | |
1946 | if (job == NULL) { | 1963 | if (job == NULL) { | |
1964 | if (isJobs) { | |||
1947 | if (!lurking_children) | 1965 | if (!lurking_children) | |
1948 | Error("Child (%d) status %x not in table?", pid, status); | 1966 | Error("Child (%d) status %x not in table?", pid, status); | |
1949 | continue; | |||
1950 | } | 1967 | } | |
1951 | if (WIFSTOPPED(status)) { | 1968 | return; /* not ours */ | |
1952 | if (DEBUG(JOB)) { | 1969 | } | |
1953 | (void)fprintf(debug_file, "Process %d (%s) stopped.\n", | 1970 | if (WIFSTOPPED(status)) { | |
1954 | job->pid, job->node->name); | 1971 | if (DEBUG(JOB)) { | |
1955 | } | 1972 | (void)fprintf(debug_file, "Process %d (%s) stopped.\n", | |
1956 | if (!make_suspended) { | 1973 | job->pid, job->node->name); | |
1957 | switch (WSTOPSIG(status)) { | 1974 | } | |
1958 | case SIGTSTP: | 1975 | if (!make_suspended) { | |
1959 | (void)printf("*** [%s] Suspended\n", job->node->name); | 1976 | switch (WSTOPSIG(status)) { | |
1960 | break; | 1977 | case SIGTSTP: | |
1961 | case SIGSTOP: | 1978 | (void)printf("*** [%s] Suspended\n", job->node->name); | |
1962 | (void)printf("*** [%s] Stopped\n", job->node->name); | 1979 | break; | |
1963 | break; | 1980 | case SIGSTOP: | |
1964 | default: | 1981 | (void)printf("*** [%s] Stopped\n", job->node->name); | |
1965 | (void)printf("*** [%s] Stopped -- signal %d\n", | 1982 | break; | |
1966 | job->node->name, WSTOPSIG(status)); | 1983 | default: | |
1967 | } | 1984 | (void)printf("*** [%s] Stopped -- signal %d\n", | |
1968 | job->job_suspended = 1; | 1985 | job->node->name, WSTOPSIG(status)); | |
1969 | } | 1986 | } | |
1970 | (void)fflush(stdout); | 1987 | job->job_suspended = 1; | |
1971 | continue; | |||
1972 | } | 1988 | } | |
1989 | (void)fflush(stdout); | |||
1990 | return; | |||
1991 | } | |||
1973 | 1992 | |||
1974 | job->job_state = JOB_ST_FINISHED; | 1993 | job->job_state = JOB_ST_FINISHED; | |
1975 | job->exit_status = status; | 1994 | job->exit_status = status; | |
1976 | 1995 | |||
1977 | JobFinish(job, status); | 1996 | JobFinish(job, status); | |
1978 | } | |||
1979 | } | 1997 | } | |
1980 | 1998 | |||
1981 | /*- | 1999 | /*- | |
1982 | *----------------------------------------------------------------------- | 2000 | *----------------------------------------------------------------------- | |
1983 | * Job_CatchOutput -- | 2001 | * Job_CatchOutput -- | |
1984 | * Catch the output from our children, if we're using | 2002 | * Catch the output from our children, if we're using | |
1985 | * pipes do so. Otherwise just block time until we get a | 2003 | * pipes do so. Otherwise just block time until we get a | |
1986 | * signal(most likely a SIGCHLD) since there's no point in | 2004 | * signal(most likely a SIGCHLD) since there's no point in | |
1987 | * just spinning when there's nothing to do and the reaping | 2005 | * just spinning when there's nothing to do and the reaping | |
1988 | * of a child can wait for a while. | 2006 | * of a child can wait for a while. | |
1989 | * | 2007 | * | |
1990 | * Results: | 2008 | * Results: | |
1991 | * None | 2009 | * None |
--- src/usr.bin/make/main.c 2010/06/03 15:40:16 1.188
+++ src/usr.bin/make/main.c 2010/08/07 06:44:08 1.189
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main.c,v 1.188 2010/06/03 15:40:16 sjg Exp $ */ | 1 | /* $NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | 4 | * Copyright (c) 1988, 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -59,39 +59,39 @@ | @@ -59,39 +59,39 @@ | |||
59 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 59 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
60 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 60 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
61 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 61 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
62 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 62 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
63 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 63 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
64 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 64 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
65 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 65 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 66 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
68 | * SUCH DAMAGE. | 68 | * SUCH DAMAGE. | |
69 | */ | 69 | */ | |
70 | 70 | |||
71 | #ifndef MAKE_NATIVE | 71 | #ifndef MAKE_NATIVE | |
72 | static char rcsid[] = "$NetBSD: main.c,v 1.188 2010/06/03 15:40:16 sjg Exp $"; | 72 | static char rcsid[] = "$NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $"; | |
73 | #else | 73 | #else | |
74 | #include <sys/cdefs.h> | 74 | #include <sys/cdefs.h> | |
75 | #ifndef lint | 75 | #ifndef lint | |
76 | __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ | 76 | __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ | |
77 | The Regents of the University of California. All rights reserved."); | 77 | The Regents of the University of California. All rights reserved."); | |
78 | #endif /* not lint */ | 78 | #endif /* not lint */ | |
79 | 79 | |||
80 | #ifndef lint | 80 | #ifndef lint | |
81 | #if 0 | 81 | #if 0 | |
82 | static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; | 82 | static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; | |
83 | #else | 83 | #else | |
84 | __RCSID("$NetBSD: main.c,v 1.188 2010/06/03 15:40:16 sjg Exp $"); | 84 | __RCSID("$NetBSD: main.c,v 1.189 2010/08/07 06:44:08 sjg Exp $"); | |
85 | #endif | 85 | #endif | |
86 | #endif /* not lint */ | 86 | #endif /* not lint */ | |
87 | #endif | 87 | #endif | |
88 | 88 | |||
89 | /*- | 89 | /*- | |
90 | * main.c -- | 90 | * main.c -- | |
91 | * The main file for this entire program. Exit routines etc | 91 | * The main file for this entire program. Exit routines etc | |
92 | * reside here. | 92 | * reside here. | |
93 | * | 93 | * | |
94 | * Utility functions defined in this file: | 94 | * Utility functions defined in this file: | |
95 | * Main_ParseArgLine Takes a line of arguments, breaks them and | 95 | * Main_ParseArgLine Takes a line of arguments, breaks them and | |
96 | * treats them as if they were given when first | 96 | * treats them as if they were given when first | |
97 | * invoked. Used by the parse module to implement | 97 | * invoked. Used by the parse module to implement | |
@@ -1631,29 +1631,30 @@ Cmd_Exec(const char *cmd, const char **e | @@ -1631,29 +1631,30 @@ Cmd_Exec(const char *cmd, const char **e | |||
1631 | if (cc > 0) | 1631 | if (cc > 0) | |
1632 | Buf_AddBytes(&buf, cc, result); | 1632 | Buf_AddBytes(&buf, cc, result); | |
1633 | } | 1633 | } | |
1634 | while (cc > 0 || (cc == -1 && errno == EINTR)); | 1634 | while (cc > 0 || (cc == -1 && errno == EINTR)); | |
1635 | 1635 | |||
1636 | /* | 1636 | /* | |
1637 | * Close the input side of the pipe. | 1637 | * Close the input side of the pipe. | |
1638 | */ | 1638 | */ | |
1639 | (void)close(fds[0]); | 1639 | (void)close(fds[0]); | |
1640 | 1640 | |||
1641 | /* | 1641 | /* | |
1642 | * Wait for the process to exit. | 1642 | * Wait for the process to exit. | |
1643 | */ | 1643 | */ | |
1644 | while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0)) | 1644 | while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0)) { | |
1645 | JobReapChild(pid, status, FALSE); | |||
1645 | continue; | 1646 | continue; | |
1646 | 1647 | } | ||
1647 | cc = Buf_Size(&buf); | 1648 | cc = Buf_Size(&buf); | |
1648 | res = Buf_Destroy(&buf, FALSE); | 1649 | res = Buf_Destroy(&buf, FALSE); | |
1649 | 1650 | |||
1650 | if (cc == 0) | 1651 | if (cc == 0) | |
1651 | *errnum = "Couldn't read shell's output for \"%s\""; | 1652 | *errnum = "Couldn't read shell's output for \"%s\""; | |
1652 | 1653 | |||
1653 | if (WIFSIGNALED(status)) | 1654 | if (WIFSIGNALED(status)) | |
1654 | *errnum = "\"%s\" exited on a signal"; | 1655 | *errnum = "\"%s\" exited on a signal"; | |
1655 | else if (WEXITSTATUS(status) != 0) | 1656 | else if (WEXITSTATUS(status) != 0) | |
1656 | *errnum = "\"%s\" returned non-zero status"; | 1657 | *errnum = "\"%s\" returned non-zero status"; | |
1657 | 1658 | |||
1658 | /* | 1659 | /* | |
1659 | * Null-terminate the result, convert newlines to spaces and | 1660 | * Null-terminate the result, convert newlines to spaces and |
--- src/usr.bin/make/Attic/nonints.h 2010/06/03 15:40:16 1.59
+++ src/usr.bin/make/Attic/nonints.h 2010/08/07 06:44:08 1.60
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: nonints.h,v 1.59 2010/06/03 15:40:16 sjg Exp $ */ | 1 | /* $NetBSD: nonints.h,v 1.60 2010/08/07 06:44:08 sjg Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | 4 | * Copyright (c) 1988, 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -96,26 +96,29 @@ int Compat_Make(void *, void *); | @@ -96,26 +96,29 @@ int Compat_Make(void *, void *); | |||
96 | 96 | |||
97 | /* cond.c */ | 97 | /* cond.c */ | |
98 | struct If; | 98 | struct If; | |
99 | int Cond_EvalExpression(const struct If *, char *, Boolean *, int); | 99 | int Cond_EvalExpression(const struct If *, char *, Boolean *, int); | |
100 | int Cond_Eval(char *); | 100 | int Cond_Eval(char *); | |
101 | void Cond_restore_depth(unsigned int); | 101 | void Cond_restore_depth(unsigned int); | |
102 | unsigned int Cond_save_depth(void); | 102 | unsigned int Cond_save_depth(void); | |
103 | 103 | |||
104 | /* for.c */ | 104 | /* for.c */ | |
105 | int For_Eval(char *); | 105 | int For_Eval(char *); | |
106 | int For_Accum(char *); | 106 | int For_Accum(char *); | |
107 | void For_Run(int); | 107 | void For_Run(int); | |
108 | 108 | |||
109 | /* job.c */ | |||
110 | void JobReapChild(pid_t, int, Boolean); | |||
111 | ||||
109 | /* main.c */ | 112 | /* main.c */ | |
110 | void Main_ParseArgLine(const char *); | 113 | void Main_ParseArgLine(const char *); | |
111 | void MakeMode(const char *); | 114 | void MakeMode(const char *); | |
112 | int main(int, char **); | 115 | int main(int, char **); | |
113 | char *Cmd_Exec(const char *, const char **); | 116 | char *Cmd_Exec(const char *, const char **); | |
114 | void Error(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); | 117 | void Error(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); | |
115 | void Fatal(const char *, ...) | 118 | void Fatal(const char *, ...) | |
116 | __attribute__((__format__(__printf__, 1, 2),__noreturn__)); | 119 | __attribute__((__format__(__printf__, 1, 2),__noreturn__)); | |
117 | void Punt(const char *, ...) | 120 | void Punt(const char *, ...) | |
118 | __attribute__((__format__(__printf__, 1, 2),__noreturn__)); | 121 | __attribute__((__format__(__printf__, 1, 2),__noreturn__)); | |
119 | void DieHorribly(void) __attribute__((__noreturn__)); | 122 | void DieHorribly(void) __attribute__((__noreturn__)); | |
120 | int PrintAddr(void *, void *); | 123 | int PrintAddr(void *, void *); | |
121 | void Finish(int); | 124 | void Finish(int); |