version 1.67, 2007/09/17 08:36:57 |
version 1.68, 2007/09/17 09:28:36 |
|
|
/*- |
/*- |
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
* JobPassSig -- |
* JobPassSig -- |
* Pass a signal to all local jobs if USE_PGRP is defined, |
* Pass a signal to all local jobs if USE_PGRP is defined, |
* then die ourselves. |
* then die ourselves. |
* |
* |
* Side Effects: |
* Side Effects: |
|
|
* echoOff command. Otherwise we issue it and pretend it was on |
* echoOff command. Otherwise we issue it and pretend it was on |
* for the whole command... |
* for the whole command... |
*/ |
*/ |
if (!shutUp && !(job->flags & JOB_SILENT) && |
if (!shutUp && !(job->flags & JOB_SILENT) && |
commandShell->hasEchoCtl){ |
commandShell->hasEchoCtl){ |
DBPRINTF("%s\n", commandShell->echoOff); |
DBPRINTF("%s\n", commandShell->echoOff); |
shutUp = true; |
shutUp = true; |
|
|
|
|
if (WIFEXITED(*status)) { |
if (WIFEXITED(*status)) { |
if (DEBUG(JOB)) { |
if (DEBUG(JOB)) { |
(void)fprintf(stdout, "Process %ld exited.\n", |
(void)fprintf(stdout, "Process %ld exited.\n", |
(long)job->pid); |
(long)job->pid); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
} |
} |
(void)fprintf(out, "*** Error code %d%s\n", |
(void)fprintf(out, "*** Error code %d%s\n", |
WEXITSTATUS(*status), |
WEXITSTATUS(*status), |
(job->flags & JOB_IGNERR) ? "(ignored)" : |
(job->flags & JOB_IGNERR) ? "(ignored)" : |
""); |
""); |
|
|
if (job->flags & JOB_IGNERR) { |
if (job->flags & JOB_IGNERR) { |
|
|
MESSAGE(out, job->node); |
MESSAGE(out, job->node); |
lastNode = job->node; |
lastNode = job->node; |
} |
} |
(void)fprintf(out, |
(void)fprintf(out, |
"*** Completed successfully\n"); |
"*** Completed successfully\n"); |
} |
} |
} else if (WIFSTOPPED(*status)) { |
} else if (WIFSTOPPED(*status)) { |
if (DEBUG(JOB)) { |
if (DEBUG(JOB)) { |
(void)fprintf(stdout, "Process %ld stopped.\n", |
(void)fprintf(stdout, "Process %ld stopped.\n", |
(long)job->pid); |
(long)job->pid); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
if (nJobs == maxJobs) { |
if (nJobs == maxJobs) { |
jobFull = true; |
jobFull = true; |
if (DEBUG(JOB)) { |
if (DEBUG(JOB)) { |
(void)fprintf(stdout, |
(void)fprintf(stdout, |
"Job queue is full.\n"); |
"Job queue is full.\n"); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
MESSAGE(out, job->node); |
MESSAGE(out, job->node); |
lastNode = job->node; |
lastNode = job->node; |
} |
} |
(void)fprintf(out, "*** Signal %d\n", |
(void)fprintf(out, "*** Signal %d\n", |
WTERMSIG(*status)); |
WTERMSIG(*status)); |
} |
} |
|
|
|
|
int bytes, obytes; |
int bytes, obytes; |
char *tmp; |
char *tmp; |
|
|
bytes = howmany(job->inPipe+1, NFDBITS) * |
bytes = howmany(job->inPipe+1, NFDBITS) * |
sizeof(fd_mask); |
sizeof(fd_mask); |
obytes = outputsn ? |
obytes = outputsn ? |
howmany(outputsn+1, NFDBITS) * |
howmany(outputsn+1, NFDBITS) * |
sizeof(fd_mask) : 0; |
sizeof(fd_mask) : 0; |
|
|
if (bytes != obytes) { |
if (bytes != obytes) { |
|
|
JobMakeArgv(job, argv); |
JobMakeArgv(job, argv); |
|
|
if (DEBUG(JOB)) { |
if (DEBUG(JOB)) { |
(void)fprintf(stdout, "Restarting %s...", |
(void)fprintf(stdout, "Restarting %s...", |
job->node->name); |
job->node->name); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
* sanity |
* sanity |
*/ |
*/ |
numCommands = 0; |
numCommands = 0; |
Lst_ForEachNodeWhile(&gn->commands, JobPrintCommand, |
Lst_ForEachNodeWhile(&gn->commands, JobPrintCommand, |
job); |
job); |
|
|
/* |
/* |
|
|
* good. |
* good. |
*/ |
*/ |
if (cmdsOK) { |
if (cmdsOK) { |
Lst_ForEachNodeWhile(&gn->commands, JobPrintCommand, |
Lst_ForEachNodeWhile(&gn->commands, JobPrintCommand, |
job); |
job); |
} |
} |
/* |
/* |
|
|
*/ |
*/ |
if (cmdsOK) { |
if (cmdsOK) { |
if (aborting == 0) { |
if (aborting == 0) { |
Lst_ForEachFrom(job->tailCmds, JobSaveCommand, |
Lst_ForEachFrom(job->tailCmds, JobSaveCommand, |
job->node); |
job->node); |
Make_Update(job->node); |
Make_Update(job->node); |
} |
} |
|
|
} else { |
} else { |
(void)fprintf(stdout, "Remaking `%s'\n", gn->name); |
(void)fprintf(stdout, "Remaking `%s'\n", gn->name); |
(void)fflush(stdout); |
(void)fflush(stdout); |
(void)strlcpy(job->outFile, TMPPAT, |
(void)strlcpy(job->outFile, TMPPAT, |
sizeof(job->outFile)); |
sizeof(job->outFile)); |
if ((job->outFd = mkstemp(job->outFile)) == -1) |
if ((job->outFd = mkstemp(job->outFile)) == -1) |
Punt("Cannot create temp file: %s", |
Punt("Cannot create temp file: %s", |
strerror(errno)); |
strerror(errno)); |
(void)fcntl(job->outFd, F_SETFD, 1); |
(void)fcntl(job->outFd, F_SETFD, 1); |
} |
} |
|
|
*/ |
*/ |
jobFull = true; |
jobFull = true; |
if (DEBUG(JOB)) { |
if (DEBUG(JOB)) { |
(void)fprintf(stdout, |
(void)fprintf(stdout, |
"Local job queue is full.\n"); |
"Local job queue is full.\n"); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
* non-printable command.... |
* non-printable command.... |
*/ |
*/ |
cp++; |
cp++; |
while (*cp == ' ' || *cp == '\t' || |
while (*cp == ' ' || *cp == '\t' || |
*cp == '\n') { |
*cp == '\n') { |
cp++; |
cp++; |
} |
} |
|
|
if (i >= job->curPos) { |
if (i >= job->curPos) { |
char *cp; |
char *cp; |
|
|
cp = JobOutput(job, job->outBuf, |
cp = JobOutput(job, job->outBuf, |
&job->outBuf[i], false); |
&job->outBuf[i], false); |
|
|
/* |
/* |
|
|
MESSAGE(stdout, job->node); |
MESSAGE(stdout, job->node); |
lastNode = job->node; |
lastNode = job->node; |
} |
} |
(void)fprintf(stdout, "%s%s", cp, |
(void)fprintf(stdout, "%s%s", cp, |
gotNL ? "\n" : ""); |
gotNL ? "\n" : ""); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
} |
} |
if (i < max - 1) { |
if (i < max - 1) { |
/* shift the remaining characters down */ |
/* shift the remaining characters down */ |
(void)memcpy(job->outBuf, &job->outBuf[i + 1], |
(void)memcpy(job->outBuf, &job->outBuf[i + 1], |
max - (i + 1)); |
max - (i + 1)); |
job->curPos = max - (i + 1); |
job->curPos = max - (i + 1); |
|
|
|
|
*/ |
*/ |
oFILE = fopen(job->outFile, "r"); |
oFILE = fopen(job->outFile, "r"); |
if (oFILE != NULL) { |
if (oFILE != NULL) { |
(void)fprintf(stdout, "Results of making %s:\n", |
(void)fprintf(stdout, "Results of making %s:\n", |
job->node->name); |
job->node->name); |
(void)fflush(stdout); |
(void)fflush(stdout); |
while (fgets(inLine, sizeof(inLine), oFILE) != NULL) { |
while (fgets(inLine, sizeof(inLine), oFILE) != NULL) { |
|
|
(block?0:WNOHANG)|WUNTRACED)) > 0) { |
(block?0:WNOHANG)|WUNTRACED)) > 0) { |
HandleSigs(); |
HandleSigs(); |
if (DEBUG(JOB)) { |
if (DEBUG(JOB)) { |
(void)fprintf(stdout, |
(void)fprintf(stdout, |
"Process %ld exited or stopped.\n", (long)pid); |
"Process %ld exited or stopped.\n", (long)pid); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
jnode = Lst_Find(&jobs, JobCmpPid, &pid); |
jnode = Lst_Find(&jobs, JobCmpPid, &pid); |
|
|
if (jnode == NULL) { |
if (jnode == NULL) { |
if (WIFSIGNALED(status) && |
if (WIFSIGNALED(status) && |
(WTERMSIG(status) == SIGCONT)) { |
(WTERMSIG(status) == SIGCONT)) { |
jnode = Lst_Find(&stoppedJobs, JobCmpPid, &pid); |
jnode = Lst_Find(&stoppedJobs, JobCmpPid, &pid); |
if (jnode == NULL) { |
if (jnode == NULL) { |
|
|
Lst_Remove(&jobs, jnode); |
Lst_Remove(&jobs, jnode); |
nJobs--; |
nJobs--; |
if (jobFull && DEBUG(JOB)) { |
if (jobFull && DEBUG(JOB)) { |
(void)fprintf(stdout, |
(void)fprintf(stdout, |
"Job queue is no longer full.\n"); |
"Job queue is no longer full.\n"); |
(void)fflush(stdout); |
(void)fflush(stdout); |
} |
} |
|
|
return; |
return; |
} else { |
} else { |
HandleSigs(); |
HandleSigs(); |
for (ln = Lst_First(&jobs); nfds && ln != NULL; |
for (ln = Lst_First(&jobs); nfds && ln != NULL; |
ln = Lst_Adv(ln)) { |
ln = Lst_Adv(ln)) { |
job = (Job *)Lst_Datum(ln); |
job = (Job *)Lst_Datum(ln); |
if (FD_ISSET(job->inPipe, readfdsp)) { |
if (FD_ISSET(job->inPipe, readfdsp)) { |