| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: job.c,v 1.215 2020/08/23 18:26:35 rillig Exp $ */ | | 1 | /* $NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig 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.215 2020/08/23 18:26:35 rillig Exp $"; | | 73 | static char rcsid[] = "$NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig 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.215 2020/08/23 18:26:35 rillig Exp $"); | | 80 | __RCSID("$NetBSD: job.c,v 1.216 2020/08/27 06:31:46 rillig 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 |
| @@ -1091,29 +1091,29 @@ JobFinish(Job *job, int status) | | | @@ -1091,29 +1091,29 @@ JobFinish(Job *job, int status) |
1091 | (aborting == ABORT_ERROR) || | | 1091 | (aborting == ABORT_ERROR) || |
1092 | (aborting == ABORT_INTERRUPT)) | | 1092 | (aborting == ABORT_INTERRUPT)) |
1093 | return_job_token = TRUE; | | 1093 | return_job_token = TRUE; |
1094 | } | | 1094 | } |
1095 | | | 1095 | |
1096 | if ((aborting != ABORT_ERROR) && (aborting != ABORT_INTERRUPT) && (status == 0)) { | | 1096 | if ((aborting != ABORT_ERROR) && (aborting != ABORT_INTERRUPT) && (status == 0)) { |
1097 | /* | | 1097 | /* |
1098 | * As long as we aren't aborting and the job didn't return a non-zero | | 1098 | * As long as we aren't aborting and the job didn't return a non-zero |
1099 | * status that we shouldn't ignore, we call Make_Update to update | | 1099 | * status that we shouldn't ignore, we call Make_Update to update |
1100 | * the parents. In addition, any saved commands for the node are placed | | 1100 | * the parents. In addition, any saved commands for the node are placed |
1101 | * on the .END target. | | 1101 | * on the .END target. |
1102 | */ | | 1102 | */ |
1103 | if (job->tailCmds != NULL) { | | 1103 | if (job->tailCmds != NULL) { |
1104 | Lst_ForEachFrom(job->node->commands, job->tailCmds, | | 1104 | Lst_ForEachFromS(job->node->commands, job->tailCmds, |
1105 | JobSaveCommand, | | 1105 | JobSaveCommand, |
1106 | job->node); | | 1106 | job->node); |
1107 | } | | 1107 | } |
1108 | job->node->made = MADE; | | 1108 | job->node->made = MADE; |
1109 | if (!(job->flags & JOB_SPECIAL)) | | 1109 | if (!(job->flags & JOB_SPECIAL)) |
1110 | return_job_token = TRUE; | | 1110 | return_job_token = TRUE; |
1111 | Make_Update(job->node); | | 1111 | Make_Update(job->node); |
1112 | job->job_state = JOB_ST_FREE; | | 1112 | job->job_state = JOB_ST_FREE; |
1113 | } else if (status != 0) { | | 1113 | } else if (status != 0) { |
1114 | errors += 1; | | 1114 | errors += 1; |
1115 | job->job_state = JOB_ST_FREE; | | 1115 | job->job_state = JOB_ST_FREE; |
1116 | } | | 1116 | } |
1117 | | | 1117 | |
1118 | /* | | 1118 | /* |
1119 | * Set aborting if any error. | | 1119 | * Set aborting if any error. |
| @@ -1714,29 +1714,29 @@ JobStart(GNode *gn, int flags) | | | @@ -1714,29 +1714,29 @@ JobStart(GNode *gn, int flags) |
1714 | if (job->cmdFILE != stdout) { | | 1714 | if (job->cmdFILE != stdout) { |
1715 | if (job->cmdFILE != NULL) { | | 1715 | if (job->cmdFILE != NULL) { |
1716 | (void)fclose(job->cmdFILE); | | 1716 | (void)fclose(job->cmdFILE); |
1717 | job->cmdFILE = NULL; | | 1717 | job->cmdFILE = NULL; |
1718 | } | | 1718 | } |
1719 | } | | 1719 | } |
1720 | | | 1720 | |
1721 | /* | | 1721 | /* |
1722 | * We only want to work our way up the graph if we aren't here because | | 1722 | * We only want to work our way up the graph if we aren't here because |
1723 | * the commands for the job were no good. | | 1723 | * the commands for the job were no good. |
1724 | */ | | 1724 | */ |
1725 | if (cmdsOK && aborting == 0) { | | 1725 | if (cmdsOK && aborting == 0) { |
1726 | if (job->tailCmds != NULL) { | | 1726 | if (job->tailCmds != NULL) { |
1727 | Lst_ForEachFrom(job->node->commands, job->tailCmds, | | 1727 | Lst_ForEachFromS(job->node->commands, job->tailCmds, |
1728 | JobSaveCommand, | | 1728 | JobSaveCommand, |
1729 | job->node); | | 1729 | job->node); |
1730 | } | | 1730 | } |
1731 | job->node->made = MADE; | | 1731 | job->node->made = MADE; |
1732 | Make_Update(job->node); | | 1732 | Make_Update(job->node); |
1733 | } | | 1733 | } |
1734 | job->job_state = JOB_ST_FREE; | | 1734 | job->job_state = JOB_ST_FREE; |
1735 | return cmdsOK ? JOB_FINISHED : JOB_ERROR; | | 1735 | return cmdsOK ? JOB_FINISHED : JOB_ERROR; |
1736 | } | | 1736 | } |
1737 | | | 1737 | |
1738 | /* | | 1738 | /* |
1739 | * Set up the control arguments to the shell. This is based on the flags | | 1739 | * Set up the control arguments to the shell. This is based on the flags |
1740 | * set earlier for this job. | | 1740 | * set earlier for this job. |
1741 | */ | | 1741 | */ |
1742 | JobMakeArgv(job, argv); | | 1742 | JobMakeArgv(job, argv); |