diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-01 23:20:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-01 23:20:38 +0000 |
commit | 02c10b77cdec682bc2c059683b30656cd6348531 (patch) | |
tree | 66d313cd009e9316bb2ecf36b503604de91bd2ef /usr.bin/tmux/job.c | |
parent | c412fabe01785366debb0e53069d3ce9fdb89b6f (diff) |
Add a flag for jobs that shouldn't be freed after they've died and use it for
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.
Fixes problems with changing options from inside #().
Diffstat (limited to 'usr.bin/tmux/job.c')
-rw-r--r-- | usr.bin/tmux/job.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c index 0d6479cabac..fa579110f70 100644 --- a/usr.bin/tmux/job.c +++ b/usr.bin/tmux/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.8 2009/10/21 18:20:16 nicm Exp $ */ +/* $OpenBSD: job.c,v 1.9 2009/11/01 23:20:37 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -73,7 +73,7 @@ job_get(struct jobs *jobs, const char *cmd) /* Add a job. */ struct job * -job_add(struct jobs *jobs, struct client *c, const char *cmd, +job_add(struct jobs *jobs, int flags, struct client *c, const char *cmd, void (*callbackfn)(struct job *), void (*freefn)(void *), void *data) { struct job *job; @@ -81,6 +81,7 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd, job = xmalloc(sizeof *job); job->cmd = xstrdup(cmd); job->pid = -1; + job->status = 0; job->client = c; @@ -91,15 +92,24 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd, job->freefn = freefn; job->data = data; - job->flags = JOB_DONE; + job->flags = flags|JOB_DONE; if (jobs != NULL) RB_INSERT(jobs, jobs, job); SLIST_INSERT_HEAD(&all_jobs, job, lentry); - + return (job); } +/* Remove job from tree and free. */ +void +job_remove(struct jobs *jobs, struct job *job) +{ + if (jobs != NULL) + RB_REMOVE(jobs, jobs, job); + job_free(job); +} + /* Kill and free an individual job. */ void job_free(struct job *job) |