--- src/usr.bin/make/job.c 2005/04/28 18:47:09 1.82 +++ src/usr.bin/make/job.c 2005/04/28 18:47:27 1.83 @@ -1018,111 +1018,154 @@ JobFinish(Job *job, int *status) done = FALSE; } - if (done || WIFSTOPPED(*status) || - (WIFSIGNALED(*status) && WTERMSIG(*status) == SIGCONT) || - DEBUG(JOB)) { - FILE *out; - - if (compatMake && !usePipes && (job->flags & JOB_IGNERR)) { - /* - * If output is going to a file and this job is ignoring - * errors, arrange to have the exit status sent to the - * output file as well. - */ - out = fdopen(job->outFd, "w"); - if (out == NULL) - Punt("Cannot fdopen"); - } else { - out = stdout; - } + if (WIFEXITED(*status)) { + if (done || DEBUG(JOB)) { + FILE *out; + + if (compatMake && + !usePipes && + (job->flags & JOB_IGNERR)) { + /* + * If output is going to a file and this job + * is ignoring errors, arrange to have the + * exit status sent to the output file as + * well. + */ + out = fdopen(job->outFd, "w"); + if (out == NULL) + Punt("Cannot fdopen"); + } else { + out = stdout; + } - if (WIFEXITED(*status)) { DEBUGF(JOB, ("Process %jd exited.\n", (intmax_t)job->pid)); - if (WEXITSTATUS(*status) != 0) { + + if (WEXITSTATUS(*status) == 0) { + if (DEBUG(JOB)) { + if (usePipes && job->node != lastNode) { + MESSAGE(out, job->node); + lastNode = job->node; + } + fprintf(out, + "*** Completed successfully\n"); + } + } else { if (usePipes && job->node != lastNode) { MESSAGE(out, job->node); lastNode = job->node; } fprintf(out, "*** Error code %d%s\n", - WEXITSTATUS(*status), - (job->flags & JOB_IGNERR) ? - "(ignored)" : ""); + WEXITSTATUS(*status), + (job->flags & JOB_IGNERR) ? + "(ignored)" : ""); if (job->flags & JOB_IGNERR) { *status = 0; } - } else if (DEBUG(JOB)) { - if (usePipes && job->node != lastNode) { - MESSAGE(out, job->node); - lastNode = job->node; - } - fprintf(out, "*** Completed successfully\n"); } - } else if (WIFSTOPPED(*status)) { - DEBUGF(JOB, ("Process %jd stopped.\n", - (intmax_t)job->pid)); - if (usePipes && job->node != lastNode) { - MESSAGE(out, job->node); - lastNode = job->node; - } - fprintf(out, "*** Stopped -- signal %d\n", - WSTOPSIG(*status)); - job->flags |= JOB_RESUME; - TAILQ_INSERT_TAIL(&stoppedJobs, job, link); fflush(out); - return; + } + } else if (WIFSIGNALED(*status)) { + if (done || DEBUG(JOB) || (WTERMSIG(*status) == SIGCONT)) { + FILE *out; + + if (compatMake && + !usePipes && + (job->flags & JOB_IGNERR)) { + /* + * If output is going to a file and this job + * is ignoring errors, arrange to have the + * exit status sent to the output file as + * well. + */ + out = fdopen(job->outFd, "w"); + if (out == NULL) + Punt("Cannot fdopen"); + } else { + out = stdout; + } - } else if (WTERMSIG(*status) == SIGCONT) { - /* - * If the beastie has continued, shift the Job from - * the stopped list to the running one (or re-stop it - * if concurrency is exceeded) and go and get another - * child. - */ - if (job->flags & (JOB_RESUME | JOB_RESTART)) { + if (WTERMSIG(*status) == SIGCONT) { + /* + * If the beastie has continued, shift the + * Job from the stopped list to the running + * one (or re-stop it if concurrency is + * exceeded) and go and get another child. + */ + if (job->flags & (JOB_RESUME | JOB_RESTART)) { + if (usePipes && job->node != lastNode) { + MESSAGE(out, job->node); + lastNode = job->node; + } + fprintf(out, "*** Continued\n"); + } + if (!(job->flags & JOB_CONTINUING)) { + DEBUGF(JOB, ("Warning: process %jd was not " + "continuing.\n", (intmax_t) job->pid)); +#ifdef notdef + /* + * We don't really want to restart a + * job from scratch just because it + * continued, especially not without + * killing the continuing process! + * That's why this is ifdef'ed out. + * FD - 9/17/90 + */ + JobRestart(job); +#endif + } + job->flags &= ~JOB_CONTINUING; + TAILQ_INSERT_TAIL(&jobs, job, link); + nJobs += 1; + DEBUGF(JOB, ("Process %jd is continuing locally.\n", + (intmax_t) job->pid)); + if (nJobs == maxJobs) { + jobFull = TRUE; + DEBUGF(JOB, ("Job queue is full.\n")); + } + fflush(out); + return; + + } else { if (usePipes && job->node != lastNode) { MESSAGE(out, job->node); lastNode = job->node; } - fprintf(out, "*** Continued\n"); - } - if (!(job->flags & JOB_CONTINUING)) { - DEBUGF(JOB, ("Warning: process %jd was not " - "continuing.\n", (intmax_t)job->pid)); -#ifdef notdef - /* - * We don't really want to restart a job from - * scratch just because it continued, especially - * not without killing the continuing process! - * That's why this is ifdef'ed out. - * FD - 9/17/90 - */ - JobRestart(job); -#endif + fprintf(out, + "*** Signal %d\n", WTERMSIG(*status)); + fflush(out); } - job->flags &= ~JOB_CONTINUING; - TAILQ_INSERT_TAIL(&jobs, job, link); - nJobs += 1; - DEBUGF(JOB, ("Process %jd is continuing locally.\n", - (intmax_t)job->pid)); - if (nJobs == maxJobs) { - jobFull = TRUE; - DEBUGF(JOB, ("Job queue is full.\n")); - } - fflush(out); - return; + } + } else { + /* STOPPED */ + FILE *out; + if (compatMake && !usePipes && (job->flags & JOB_IGNERR)) { + /* + * If output is going to a file and this job + * is ignoring errors, arrange to have the + * exit status sent to the output file as + * well. + */ + out = fdopen(job->outFd, "w"); + if (out == NULL) + Punt("Cannot fdopen"); } else { - if (usePipes && job->node != lastNode) { - MESSAGE(out, job->node); - lastNode = job->node; - } - fprintf(out, "*** Signal %d\n", WTERMSIG(*status)); + out = stdout; } + DEBUGF(JOB, ("Process %jd stopped.\n", (intmax_t) job->pid)); + if (usePipes && job->node != lastNode) { + MESSAGE(out, job->node); + lastNode = job->node; + } + fprintf(out, "*** Stopped -- signal %d\n", WSTOPSIG(*status)); + job->flags |= JOB_RESUME; + TAILQ_INSERT_TAIL(&stoppedJobs, job, link); fflush(out); + return; } /*