mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
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 #().
This commit is contained in:
16
job.c
16
job.c
@ -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)
|
||||
|
Reference in New Issue
Block a user