version 1.18, 2008/01/02 15:37:22 |
version 1.19, 2008/01/29 22:23:10 |
|
|
static int |
static int |
setup_and_run_command(char *cmd, GNode *gn, int dont_fork) |
setup_and_run_command(char *cmd, GNode *gn, int dont_fork) |
{ |
{ |
char *cmdStart; /* Start of expanded command */ |
|
bool silent; /* Don't print command */ |
bool silent; /* Don't print command */ |
bool doExecute; /* Execute the command */ |
bool doExecute; /* Execute the command */ |
bool errCheck; /* Check errors */ |
bool errCheck; /* Check errors */ |
|
|
errCheck = !(gn->type & OP_IGNORE); |
errCheck = !(gn->type & OP_IGNORE); |
doExecute = !noExecute; |
doExecute = !noExecute; |
|
|
cmdStart = Var_Subst(cmd, &gn->context, false); |
|
|
|
/* How can we execute a null command ? we warn the user that the |
/* How can we execute a null command ? we warn the user that the |
* command expanded to nothing (is this the right thing to do?). */ |
* command expanded to nothing (is this the right thing to do?). */ |
if (*cmdStart == '\0') { |
if (*cmd == '\0') { |
free(cmdStart); |
|
Error("%s expands to empty string", cmd); |
Error("%s expands to empty string", cmd); |
return 1; |
return 1; |
} else |
} |
cmd = cmdStart; |
|
|
|
for (;; cmd++) { |
for (;; cmd++) { |
if (*cmd == '@') |
if (*cmd == '@') |
|
|
default: |
default: |
break; |
break; |
} |
} |
free(cmdStart); |
|
|
|
/* The child is off and running. Now all we can do is wait... */ |
/* The child is off and running. Now all we can do is wait... */ |
while (1) { |
while (1) { |
|
|
signal(SIGQUIT, SIG_IGN); |
signal(SIGQUIT, SIG_IGN); |
got_signal = 0; |
got_signal = 0; |
got_SIGINT = 0; |
got_SIGINT = 0; |
run_gnode(interrupt_node, 0); |
run_gnode(interrupt_node); |
exit(255); |
exit(255); |
} |
} |
exit(255); |
exit(255); |
} |
} |
|
|
|
void |
|
expand_commands(GNode *gn) |
|
{ |
|
LstNode ln; |
|
char *cmd; |
|
|
|
for (ln = Lst_First(&gn->commands); ln != NULL; ln = Lst_Adv(ln)) { |
|
cmd = Var_Subst(Lst_Datum(ln), &gn->context, false); |
|
Lst_AtEnd(&gn->expanded, cmd); |
|
} |
|
} |
|
|
int |
int |
run_gnode(GNode *gn, int parallel) |
run_gnode(GNode *gn) |
{ |
{ |
LstNode ln, nln; |
if (gn != NULL && (gn->type & OP_DUMMY) == 0) { |
|
expand_commands(gn); |
|
} |
|
return run_prepared_gnode(gn, 0); |
|
} |
|
|
|
int |
|
run_prepared_gnode(GNode *gn, int parallel) |
|
{ |
|
char *cmd; |
|
|
if (gn != NULL && (gn->type & OP_DUMMY) == 0) { |
if (gn != NULL && (gn->type & OP_DUMMY) == 0) { |
gn->built_status = MADE; |
gn->built_status = MADE; |
for (ln = Lst_First(&gn->commands); ln != NULL; ln = nln) { |
while ((cmd = Lst_DeQueue(&gn->expanded)) != NULL) { |
nln = Lst_Adv(ln); |
if (setup_and_run_command(cmd, gn, |
if (setup_and_run_command(Lst_Datum(ln), gn, |
parallel && Lst_IsEmpty(&gn->expanded)) == 0) |
parallel && nln == NULL) == 0) |
|
break; |
break; |
|
free(cmd); |
} |
} |
|
free(cmd); |
if (got_signal && !parallel) |
if (got_signal && !parallel) |
handle_compat_interrupts(gn); |
handle_compat_interrupts(gn); |
return gn->built_status; |
return gn->built_status; |