summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-10-09 09:41:25 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-10-09 09:41:25 +0000
commit96dfd65da210e19d9fde069e6adc19b9db419785 (patch)
tree472c2f1f5a3cf6f15d2907cf8d218c486b385c0a /usr.bin/make
parent9f27e266f9a7532131383e1f51e458425c582d93 (diff)
cut up JobStart, prepare the job to be run in a separate function
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/job.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index acae80fca15..2c52b5590c0 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: job.c,v 1.97 2007/10/09 09:40:26 espie Exp $ */
+/* $OpenBSD: job.c,v 1.98 2007/10/09 09:41:24 espie Exp $ */
/* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */
/*
@@ -276,6 +276,7 @@ static void debug_printf(const char *, ...);
static FILE *new_command_file(void);
static void setup_signal(int);
static void setup_all_signals(void);
+static Job *prepare_job(GNode *, int);
static void start_queued_job(Job *);
static volatile sig_atomic_t got_signal;
@@ -1171,27 +1172,12 @@ JobRestart(Job *job)
}
}
-/*-
- *-----------------------------------------------------------------------
- * JobStart --
- * Start a target-creation process going for the target described
- * by the graph node gn.
- *
- * Side Effects:
- * A new Job node is created and added to the list of running
- * jobs. PMake is forked and a child shell created.
- *-----------------------------------------------------------------------
- */
-static void
-JobStart(GNode *gn, /* target to create */
- int flags) /* flags for the job to override normal ones.
- * e.g. JOB_SPECIAL */
+static Job *
+prepare_job(GNode *gn, int flags)
{
Job *job; /* new job descriptor */
- char *argv[4]; /* Argument vector to shell */
bool cmdsOK; /* true if the nodes commands were all right */
bool noExec; /* Set true if we decide not to run the job */
- int fd[2];
job = emalloc(sizeof(Job));
if (job == NULL) {
@@ -1324,15 +1310,39 @@ JobStart(GNode *gn, /* target to create */
Make_Update(job->node);
}
free(job);
- return;
+ return NULL;
} else {
free(job);
- return;
+ return NULL;
}
} else {
(void)fflush(job->cmdFILE);
+ return job;
}
+}
+/*-
+ *-----------------------------------------------------------------------
+ * JobStart --
+ * Start a target-creation process going for the target described
+ * by the graph node gn.
+ *
+ * Side Effects:
+ * A new Job node is created and added to the list of running
+ * jobs. PMake is forked and a child shell created.
+ *-----------------------------------------------------------------------
+ */
+static void
+JobStart(GNode *gn, /* target to create */
+ int flags) /* flags for the job to override normal ones.
+ * e.g. JOB_SPECIAL */
+{
+ Job *job;
+ char *argv[4]; /* Argument vector to shell */
+ int fd[2];
+ job = prepare_job(gn, flags);
+ if (!job)
+ return;
/* Create the pipe by which we'll get the shell's output.
*/
if (pipe(fd) == -1)