aboutsummaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-11-02 21:38:27 +0000
committerTiago Cunha <tcunha@gmx.com>2009-11-02 21:38:27 +0000
commit053e40572c32d021ad8bd2922c97c5e6dcbe2c81 (patch)
tree90363ff5fecbb52e5f6ee2af5a47af93765c974d /job.c
parent47f69075a0d9abf031585eb86bea1646a3bf32eb (diff)
downloadrtmux-053e40572c32d021ad8bd2922c97c5e6dcbe2c81.tar.gz
rtmux-053e40572c32d021ad8bd2922c97c5e6dcbe2c81.tar.bz2
rtmux-053e40572c32d021ad8bd2922c97c5e6dcbe2c81.zip
Sync OpenBSD patchset 475:
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 'job.c')
-rw-r--r--job.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/job.c b/job.c
index 3b735840..cd263325 100644
--- a/job.c
+++ b/job.c
@@ -1,4 +1,4 @@
-/* $Id: job.c,v 1.8 2009-10-23 17:27:40 tcunha Exp $ */
+/* $Id: job.c,v 1.9 2009-11-02 21:38:26 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -72,7 +72,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;
@@ -80,6 +80,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;
@@ -90,15 +91,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)