summaryrefslogtreecommitdiffstats
path: root/job.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-10-11 07:20:16 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-10-11 07:20:16 +0000
commitff4b4e667a64b30e4323df4b0e1637fc7ebae6c1 (patch)
tree23eecd0ffd3bf3f5a954b484bcfbe348e29ab037 /job.c
parent4bc0f6e7e9eac73f7a1221ed4c2854d12eb1cf7e (diff)
Collect status from dead jobs and don't invoke the callback until both
all input (the socket is closed) and status is available.
Diffstat (limited to 'job.c')
-rw-r--r--job.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/job.c b/job.c
index 53b05bb4..df515b37 100644
--- a/job.c
+++ b/job.c
@@ -105,6 +105,8 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd,
job->freefn = freefn;
job->data = data;
+ job->flags = JOB_DONE;
+
RB_INSERT(jobs, jobs, job);
SLIST_INSERT_HEAD(&all_jobs, job, lentry);
@@ -133,8 +135,9 @@ job_run(struct job *job)
{
int nullfd, out[2], mode;
- if (job->fd != -1)
+ if (!(job->flags & JOB_DONE))
return (0);
+ job->flags &= ~JOB_DONE;
if (pipe(out) != 0)
return (-1);