version 1.7, 1997/06/15 21:29:22 |
version 1.8, 1997/12/16 22:26:21 |
|
|
* (2) a job can only be run locally, but |
* (2) a job can only be run locally, but |
* nLocal equals maxLocal */ |
* nLocal equals maxLocal */ |
#ifndef RMT_WILL_WATCH |
#ifndef RMT_WILL_WATCH |
static fd_set outputs; /* Set of descriptors of pipes connected to |
static fd_set *outputsp; /* Set of descriptors of pipes connected to |
* the output channels of children */ |
* the output channels of children */ |
|
static int outputsn; |
#endif |
#endif |
|
|
STATIC GNode *lastNode; /* The node for which output was most recently |
STATIC GNode *lastNode; /* The node for which output was most recently |
|
|
#ifdef RMT_WILL_WATCH |
#ifdef RMT_WILL_WATCH |
Rmt_Ignore(job->inPipe); |
Rmt_Ignore(job->inPipe); |
#else |
#else |
FD_CLR(job->inPipe, &outputs); |
FD_CLR(job->inPipe, outputsp); |
#endif |
#endif |
if (job->outPipe != job->inPipe) { |
if (job->outPipe != job->inPipe) { |
(void) close(job->outPipe); |
(void) close(job->outPipe); |
|
|
_exit(1); |
_exit(1); |
} else { |
} else { |
#ifdef REMOTE |
#ifdef REMOTE |
long omask = sigblock(sigmask(SIGCHLD)); |
int omask = sigblock(sigmask(SIGCHLD)); |
#endif |
#endif |
job->pid = cpid; |
job->pid = cpid; |
|
|
|
|
#ifdef RMT_WILL_WATCH |
#ifdef RMT_WILL_WATCH |
Rmt_Watch(job->inPipe, JobLocalInput, job); |
Rmt_Watch(job->inPipe, JobLocalInput, job); |
#else |
#else |
FD_SET(job->inPipe, &outputs); |
if (outputsp == NULL || job->inPipe > outputsn) { |
|
int bytes = howmany(job->inPipe+1, NFDBITS) * sizeof(fd_mask); |
|
int obytes = howmany(outputsn+1, NFDBITS) * sizeof(fd_mask); |
|
|
|
if (obytes != bytes) { |
|
outputsp = realloc(outputsp, bytes); |
|
if (outputsp == NULL) |
|
return; |
|
memset(outputsp + obytes, 0, bytes - obytes); |
|
} |
|
outputsn = job->inPipe; |
|
} |
|
FD_SET(job->inPipe, outputsp); |
#endif /* RMT_WILL_WATCH */ |
#endif /* RMT_WILL_WATCH */ |
} |
} |
|
|
|
|
{ |
{ |
int nfds; |
int nfds; |
struct timeval timeout; |
struct timeval timeout; |
fd_set readfds; |
|
register LstNode ln; |
register LstNode ln; |
register Job *job; |
register Job *job; |
#ifdef RMT_WILL_WATCH |
#ifdef RMT_WILL_WATCH |
|
|
} |
} |
#else |
#else |
if (usePipes) { |
if (usePipes) { |
readfds = outputs; |
int count = howmany(outputsn+1, NFDBITS) * sizeof(fd_mask); |
|
fd_set *readfdsp = malloc(count); |
|
if (readfdsp == NULL) |
|
return; |
|
|
|
memcpy(readfdsp, outputsp, count); |
timeout.tv_sec = SEL_SEC; |
timeout.tv_sec = SEL_SEC; |
timeout.tv_usec = SEL_USEC; |
timeout.tv_usec = SEL_USEC; |
|
|
if ((nfds = select(FD_SETSIZE, &readfds, (fd_set *) 0, |
if ((nfds = select(outputsn+1, readfdsp, (fd_set *) 0, |
(fd_set *) 0, &timeout)) <= 0) |
(fd_set *) 0, &timeout)) <= 0) { |
|
free(readfdsp); |
return; |
return; |
else { |
} else { |
if (Lst_Open(jobs) == FAILURE) { |
if (Lst_Open(jobs) == FAILURE) { |
|
free(readfdsp); |
Punt("Cannot open job table"); |
Punt("Cannot open job table"); |
} |
} |
while (nfds && (ln = Lst_Next(jobs)) != NILLNODE) { |
while (nfds && (ln = Lst_Next(jobs)) != NILLNODE) { |
job = (Job *) Lst_Datum(ln); |
job = (Job *) Lst_Datum(ln); |
if (FD_ISSET(job->inPipe, &readfds)) { |
if (FD_ISSET(job->inPipe, readfdsp)) { |
JobDoOutput(job, FALSE); |
JobDoOutput(job, FALSE); |
nfds -= 1; |
nfds -= 1; |
} |
} |
} |
} |
Lst_Close(jobs); |
Lst_Close(jobs); |
} |
} |
|
free(readfdsp); |
} |
} |
#endif /* RMT_WILL_WATCH */ |
#endif /* RMT_WILL_WATCH */ |
} |
} |