diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/engine.c | 61 | ||||
-rw-r--r-- | usr.bin/make/engine.h | 4 | ||||
-rw-r--r-- | usr.bin/make/job.c | 20 |
3 files changed, 51 insertions, 34 deletions
diff --git a/usr.bin/make/engine.c b/usr.bin/make/engine.c index 8a2b12ef9be..46d53b03bde 100644 --- a/usr.bin/make/engine.c +++ b/usr.bin/make/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.22 2008/11/10 10:48:43 espie Exp $ */ +/* $OpenBSD: engine.c,v 1.23 2009/04/26 09:25:49 espie Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989 by Adam de Boor @@ -72,6 +72,7 @@ static char **recheck_command_for_shell(char **); static int setup_and_run_command(char *, GNode *, int); static void run_command(const char *, bool); +static int run_prepared_gnode(GNode *); static void handle_compat_interrupts(GNode *); bool @@ -777,29 +778,55 @@ run_gnode(GNode *gn) { if (gn != NULL && (gn->type & OP_DUMMY) == 0) { expand_commands(gn); + return run_prepared_gnode(gn); + } else { + return NOSUCHNODE; } - return run_prepared_gnode(gn, 0); } -int -run_prepared_gnode(GNode *gn, int parallel) +static int +run_prepared_gnode(GNode *gn) { char *cmd; - if (gn != NULL && (gn->type & OP_DUMMY) == 0) { - gn->built_status = MADE; - while ((cmd = Lst_DeQueue(&gn->expanded)) != NULL) { - if (setup_and_run_command(cmd, gn, - parallel && Lst_IsEmpty(&gn->expanded)) == 0) - break; - free(cmd); - } + gn->built_status = MADE; + while ((cmd = Lst_DeQueue(&gn->expanded)) != NULL) { + if (setup_and_run_command(cmd, gn, 0) == 0) + break; free(cmd); - if (got_signal && !parallel) - handle_compat_interrupts(gn); - return gn->built_status; - } else - return NOSUCHNODE; + } + free(cmd); + if (got_signal) + handle_compat_interrupts(gn); + return gn->built_status; +} + +void +run_gnode_parallel(GNode *gn) +{ + char *cmd; + + gn->built_status = MADE; + /* XXX don't bother freeing cmd, we're dead anyways ! */ + while ((cmd = Lst_DeQueue(&gn->expanded)) != NULL) { + if (setup_and_run_command(cmd, gn, + Lst_IsEmpty(&gn->expanded)) == 0) + break; + } + /* Normally, we don't reach this point, unless the last command + * ignores error, in which case we interpret the status ourselves. + */ + switch(gn->built_status) { + case MADE: + exit(0); + case ERROR: + exit(1); + default: + fprintf(stderr, + "Could not run gnode, returned %d\n", + gn->built_status); + exit(1); + } } void diff --git a/usr.bin/make/engine.h b/usr.bin/make/engine.h index e41dcf92dde..01be736e7b0 100644 --- a/usr.bin/make/engine.h +++ b/usr.bin/make/engine.h @@ -1,6 +1,6 @@ #ifndef ENGINE_H #define ENGINE_H -/* $OpenBSD: engine.h,v 1.6 2008/11/04 07:22:35 espie Exp $ */ +/* $OpenBSD: engine.h,v 1.7 2009/04/26 09:25:49 espie Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -73,7 +73,7 @@ extern volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT, extern void SigHandler(int); extern int run_gnode(GNode *); -extern int run_prepared_gnode(GNode *, int); +extern void run_gnode_parallel(GNode *); extern void expand_commands(GNode *); extern void setup_engine(void); diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 77efc00f437..b6867e437ae 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: job.c,v 1.115 2008/11/11 09:32:20 espie Exp $ */ +/* $OpenBSD: job.c,v 1.116 2009/04/26 09:25:49 espie Exp $ */ /* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */ /* @@ -714,7 +714,6 @@ JobExec(Job *job) int fds[4]; int *fdout = fds; int *fderr = fds+2; - int result; int i; if (DEBUG(JOB)) { @@ -778,18 +777,9 @@ JobExec(Job *job) if (!(nJobs == 1 && no_jobs_left())) usleep(random() % random_delay); - /* most cases won't return, but will exit directly */ - result = run_prepared_gnode(job->node, 1); - switch(result) { - case MADE: - exit(0); - case ERROR: - exit(1); - default: - fprintf(stderr, - "Could not run gnode, returned %d\n", result); - exit(1); - } + /* this exits directly */ + run_gnode_parallel(job->node); + /*NOTREACHED*/ } else { supervise_jobs = true; job->pid = cpid; @@ -1405,7 +1395,7 @@ JobInterrupt(int runINTERRUPT, /* Non-zero if commands for the .INTERRUPT int Job_Finish(void) { - if (end_node != NULL && !Lst_IsEmpty(&end_node->commands)) { + if ((end_node->type & OP_DUMMY) == 0) { if (errors) { Error("Errors reported so .END ignored"); } else { |