From fd00ec63868a78f3dee2ee129ef53028dd7d8b0d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 10 Jul 2026 10:17:41 +0100 Subject: [PATCH] Do not bind global hooks to a session. --- cmd-set-option.c | 7 ++++++- regress/set-hook-B.sh | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd-set-option.c b/cmd-set-option.c index b29872adf..5fca2cf82 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -138,6 +138,7 @@ cmd_set_hook_monitor_exec(struct cmdq_item *item, struct args *args, int window) struct cmd_find_state *target = cmdq_get_target(item), fs; struct options *oo; struct options_entry *o; + struct session *s = NULL; char *cause = NULL, *name = NULL, *format = NULL; char *expanded = NULL, *newvalue = NULL; const char *value, *old; @@ -199,7 +200,11 @@ cmd_set_hook_monitor_exec(struct cmdq_item *item, struct args *args, int window) } } - hooks_monitor_add(item, oo, name, type, id, format, &fs, target->s); + if (oo != global_options && + oo != global_s_options && + oo != global_w_options) + s = target->s; + hooks_monitor_add(item, oo, name, type, id, format, &fs, s); out: free(newvalue); diff --git a/regress/set-hook-B.sh b/regress/set-hook-B.sh index 4947af70c..0144884dc 100644 --- a/regress/set-hook-B.sh +++ b/regress/set-hook-B.sh @@ -147,4 +147,14 @@ $TMUX set -pt "$target_pane" @target-value changed || fail "set pane @target-value failed" wait_for @target-pane "$target_pane" +$TMUX new -d -s zzz-survivor || fail "new survivor session failed" +$TMUX set -g @global-after-destroy 0 || + fail "set @global-after-destroy failed" +$TMUX set-hook -g -t three -B '@global-after-destroy-session::#{session_name}' \ + 'set -g @global-after-destroy "#{hook_last}->#{hook_value}"' || + fail "set-hook -B global after destroy failed" +assert_unchanged @global-after-destroy 0 +$TMUX kill-session -t three || fail "kill destroyed monitor session failed" +wait_for @global-after-destroy 'three->zzz-survivor' + exit 0