summaryrefslogtreecommitdiffstats
path: root/cmd-set-option.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-11-01 23:20:37 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-11-01 23:20:37 +0000
commit2f813ef75d7d1cfb32d78923ae6963be7266de55 (patch)
treefed2d2ac2f0b98903eea186a19f2444a8ee99452 /cmd-set-option.c
parent32299e401039e9c88e430516e9d85d59d551b859 (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 'cmd-set-option.c')
-rw-r--r--cmd-set-option.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index a495a15d..536b623b 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -108,7 +108,10 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
struct client *c;
struct options *oo;
const struct set_option_entry *entry, *opt;
+ struct jobs *jobs;
+ struct job *job, *nextjob;
u_int i;
+ int try_again;
if (data->chflags & CMD_CHFLAG('g'))
oo = &global_s_options;
@@ -184,11 +187,34 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
}
recalculate_sizes();
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c != NULL && c->session != NULL) {
- job_tree_free(&c->status_jobs);
- job_tree_init(&c->status_jobs);
+
+ /*
+ * Special-case: kill all persistent jobs if status-left, status-right
+ * or set-titles-string have changed. Persistent jobs are only used by
+ * the status line at the moment so this works XXX.
+ */
+ if (strcmp(entry->name, "status-left") == 0 ||
+ strcmp(entry->name, "status-right") == 0 ||
+ strcmp(entry->name, "set-titles-string") == 0) {
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c == NULL || c->session == NULL)
+ continue;
+
+ jobs = &c->status_jobs;
+ do {
+ try_again = 0;
+ job = RB_ROOT(jobs);
+ while (job != NULL) {
+ nextjob = RB_NEXT(jobs, jobs, job);
+ if (job->flags & JOB_PERSIST) {
+ job_remove(jobs, job);
+ try_again = 1;
+ break;
+ }
+ job = nextjob;
+ }
+ } while (try_again);
server_redraw_client(c);
}
}