diff options
Diffstat (limited to 'usr.bin/tmux/job.c')
-rw-r--r-- | usr.bin/tmux/job.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c index 7995b6dea54..a461f5cbf5b 100644 --- a/usr.bin/tmux/job.c +++ b/usr.bin/tmux/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.35 2015/04/24 22:19:36 nicm Exp $ */ +/* $OpenBSD: job.c,v 1.36 2015/06/17 16:44:49 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -100,6 +100,8 @@ job_run(const char *cmd, struct session *s, int cwd, close(out[1]); job = xmalloc(sizeof *job); + job->state = JOB_RUNNING; + job->cmd = xstrdup(cmd); job->pid = pid; job->status = 0; @@ -167,14 +169,13 @@ job_callback(unused struct bufferevent *bufev, unused short events, void *data) log_debug("job error %p: %s, pid %ld", job, job->cmd, (long) job->pid); - if (job->pid == -1) { + if (job->state == JOB_DEAD) { if (job->callbackfn != NULL) job->callbackfn(job); job_free(job); } else { bufferevent_disable(job->event, EV_READ); - close(job->fd); - job->fd = -1; + job->state = JOB_CLOSED; } } @@ -186,10 +187,12 @@ job_died(struct job *job, int status) job->status = status; - if (job->fd == -1) { + if (job->state == JOB_CLOSED) { if (job->callbackfn != NULL) job->callbackfn(job); job_free(job); - } else + } else { job->pid = -1; + job->state = JOB_DEAD; + } } |