version 1.55, 2003/06/03 02:56:11 |
version 1.56, 2004/04/07 13:11:36 |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobCondPassSig(jobp, signop) |
JobCondPassSig(void *jobp, /* Job to biff */ |
void *jobp; /* Job to biff */ |
void *signop) /* Signal to send it */ |
void *signop; /* Signal to send it */ |
|
{ |
{ |
Job *job = (Job *)jobp; |
Job *job = (Job *)jobp; |
int signo = *(int *)signop; |
int signo = *(int *)signop; |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobPassSig(signo) |
JobPassSig(int signo) /* The signal number we've received */ |
int signo; /* The signal number we've received */ |
|
{ |
{ |
int save_errno = errno; |
int save_errno = errno; |
sigset_t nmask, omask; |
sigset_t nmask, omask; |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static int |
static int |
JobCmpPid(job, pid) |
JobCmpPid(void *job, /* job to examine */ |
void *job; /* job to examine */ |
void *pid) /* process id desired */ |
void *pid; /* process id desired */ |
|
{ |
{ |
return *(pid_t *)pid - ((Job *)job)->pid; |
return *(pid_t *)pid - ((Job *)job)->pid; |
} |
} |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static int |
static int |
JobPrintCommand(cmdp, jobp) |
JobPrintCommand(void *cmdp, /* command string to print */ |
void *cmdp; /* command string to print */ |
void *jobp) /* job for which to print it */ |
void *jobp; /* job for which to print it */ |
|
{ |
{ |
bool noSpecials; /* true if we shouldn't worry about |
bool noSpecials; /* true if we shouldn't worry about |
* inserting special commands into |
* inserting special commands into |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobSaveCommand(cmd, gn) |
JobSaveCommand(void *cmd, void *gn) |
void *cmd; |
|
void *gn; |
|
{ |
{ |
GNode *g = (GNode *)gn; |
GNode *g = (GNode *)gn; |
char *result; |
char *result; |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobClose(job) |
JobClose(Job *job) |
Job *job; |
|
{ |
{ |
if (usePipes) { |
if (usePipes) { |
FD_CLR(job->inPipe, outputsp); |
FD_CLR(job->inPipe, outputsp); |
|
|
*/ |
*/ |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
static void |
static void |
JobFinish(job, status) |
JobFinish(Job *job, /* job to finish */ |
Job *job; /* job to finish */ |
int *status) /* sub-why job went away */ |
int *status; /* sub-why job went away */ |
|
{ |
{ |
bool done; |
bool done; |
|
|
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_Touch(gn, silent) |
Job_Touch(GNode *gn, /* the node of the file to touch */ |
GNode *gn; /* the node of the file to touch */ |
bool silent) /* true if should not print messages */ |
bool silent; /* true if should not print messages */ |
|
{ |
{ |
int streamID; /* ID of stream opened to do the touch */ |
int streamID; /* ID of stream opened to do the touch */ |
|
|
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
bool |
bool |
Job_CheckCommands(gn, abortProc) |
Job_CheckCommands(GNode *gn, /* The target whose commands need |
GNode *gn; /* The target whose commands need |
* verifying */ |
* verifying */ |
void (*abortProc)(char *, ...)) /* Function to abort with message */ |
void (*abortProc)(char *, ...); |
|
/* Function to abort with message */ |
|
{ |
{ |
if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->commands) && |
if (OP_NOP(gn->type) && Lst_IsEmpty(&gn->commands) && |
(gn->type & OP_LIB) == 0) { |
(gn->type & OP_LIB) == 0) { |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobExec(job, argv) |
JobExec(Job *job, char **argv) |
Job *job; /* Job to execute */ |
|
char **argv; |
|
{ |
{ |
pid_t cpid; /* ID of new child */ |
pid_t cpid; /* ID of new child */ |
|
|
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobMakeArgv(job, argv) |
JobMakeArgv(Job *job, char **argv) |
Job *job; |
|
char **argv; |
|
{ |
{ |
int argc; |
int argc; |
static char args[10]; /* For merged arguments */ |
static char args[10]; /* For merged arguments */ |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobRestart(job) |
JobRestart(Job *job) |
Job *job; /* Job to restart */ |
|
{ |
{ |
if (job->flags & JOB_RESTART) { |
if (job->flags & JOB_RESTART) { |
/* |
/* |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static int |
static int |
JobStart(gn, flags, previous) |
JobStart(GNode *gn, /* target to create */ |
GNode *gn; /* target to create */ |
int flags, /* flags for the job to override normal ones. |
int flags; /* flags for the job to override normal ones. |
|
* e.g. JOB_SPECIAL or JOB_IGNDOTS */ |
* e.g. JOB_SPECIAL or JOB_IGNDOTS */ |
Job *previous; /* The previous Job structure for this node, |
Job *previous) /* The previous Job structure for this node, |
* if any. */ |
* if any. */ |
{ |
{ |
Job *job; /* new job descriptor */ |
Job *job; /* new job descriptor */ |
|
|
} |
} |
|
|
static char * |
static char * |
JobOutput(job, cp, endp, msg) |
JobOutput(Job *job, char *cp, char *endp, int msg) |
Job *job; |
|
char *cp, *endp; |
|
int msg; |
|
{ |
{ |
char *ecp; |
char *ecp; |
|
|
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobDoOutput(job, finish) |
JobDoOutput(Job *job, /* the job whose output needs printing */ |
Job *job; /* the job whose output needs printing */ |
bool finish) /* true if this is the last time we'll be |
bool finish; /* true if this is the last time we'll be |
|
* called for this job */ |
* called for this job */ |
{ |
{ |
bool gotNL = false; /* true if got a newline */ |
bool gotNL = false; /* true if got a newline */ |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_CatchChildren(block) |
Job_CatchChildren(bool block) /* true if should block on the wait. */ |
bool block; /* true if should block on the wait. */ |
|
{ |
{ |
pid_t pid; /* pid of dead child */ |
pid_t pid; /* pid of dead child */ |
Job *job; /* job descriptor for dead child */ |
Job *job; /* job descriptor for dead child */ |
|
|
* ----------------------------------------------------------------------- |
* ----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_CatchOutput() |
Job_CatchOutput(void) |
{ |
{ |
int nfds; |
int nfds; |
struct timeval timeout; |
struct timeval timeout; |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_Make(gn) |
Job_Make(GNode *gn) |
GNode *gn; |
|
{ |
{ |
(void)JobStart(gn, 0, NULL); |
(void)JobStart(gn, 0, NULL); |
} |
} |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_Init(maxproc, maxlocal) |
Job_Init(int maxproc, /* the greatest number of jobs which may be |
int maxproc; /* the greatest number of jobs which may be |
|
* running at one time */ |
* running at one time */ |
int maxlocal; /* the greatest number of local jobs which may |
int maxlocal) /* the greatest number of local jobs which may |
* be running at once. */ |
* be running at once. */ |
{ |
{ |
GNode *begin; /* node for commands to do at the very start */ |
GNode *begin; /* node for commands to do at the very start */ |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
bool |
bool |
Job_Full() |
Job_Full(void) |
{ |
{ |
return aborting || jobFull; |
return aborting || jobFull; |
} |
} |
|
|
* ----------------------------------------------------------------------- |
* ----------------------------------------------------------------------- |
*/ |
*/ |
bool |
bool |
Job_Empty() |
Job_Empty(void) |
{ |
{ |
if (nJobs == 0) { |
if (nJobs == 0) { |
if (!Lst_IsEmpty(&stoppedJobs) && !aborting) { |
if (!Lst_IsEmpty(&stoppedJobs) && !aborting) { |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static Shell * |
static Shell * |
JobMatchShell(name) |
JobMatchShell(char *name) /* Final component of shell path */ |
char *name; /* Final component of shell path */ |
|
{ |
{ |
Shell *sh; /* Pointer into shells table */ |
Shell *sh; /* Pointer into shells table */ |
Shell *match; /* Longest-matching shell */ |
Shell *match; /* Longest-matching shell */ |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
bool |
bool |
Job_ParseShell(line) |
Job_ParseShell(const char *line) /* The shell spec */ |
char *line; /* The shell spec */ |
|
{ |
{ |
char **words; |
char **words; |
int wordCount; |
int wordCount; |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobInterrupt(runINTERRUPT, signo) |
JobInterrupt(int runINTERRUPT, /* Non-zero if commands for the .INTERRUPT |
int runINTERRUPT; /* Non-zero if commands for the .INTERRUPT |
|
* target should be executed */ |
* target should be executed */ |
int signo; /* signal received */ |
int signo) /* signal received */ |
{ |
{ |
LstNode ln; /* element in job table */ |
LstNode ln; /* element in job table */ |
Job *job; /* job descriptor in that element */ |
Job *job; /* job descriptor in that element */ |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
int |
int |
Job_Finish() |
Job_Finish(void) |
{ |
{ |
if (postCommands != NULL && !Lst_IsEmpty(&postCommands->commands)) { |
if (postCommands != NULL && !Lst_IsEmpty(&postCommands->commands)) { |
if (errors) { |
if (errors) { |
|
|
*/ |
*/ |
#ifdef CLEANUP |
#ifdef CLEANUP |
void |
void |
Job_End() |
Job_End(void) |
{ |
{ |
efree(shellArgv); |
efree(shellArgv); |
} |
} |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_Wait() |
Job_Wait(void) |
{ |
{ |
aborting = ABORT_WAIT; |
aborting = ABORT_WAIT; |
while (nJobs != 0) { |
while (nJobs != 0) { |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
void |
void |
Job_AbortAll() |
Job_AbortAll(void) |
{ |
{ |
LstNode ln; /* element in job table */ |
LstNode ln; /* element in job table */ |
Job *job; /* the job descriptor in that element */ |
Job *job; /* the job descriptor in that element */ |
|
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
static void |
static void |
JobRestartJobs() |
JobRestartJobs(void) |
{ |
{ |
Job *job; |
Job *job; |
|
|