-
Notifications
You must be signed in to change notification settings - Fork 491
Description
Problem
The typical tmux-resurrect workflow (tmux kill-server -> restart -> restore) sends SIGHUP to all child processes. Shell exit handlers (like fish's fish_exit event) do not run on SIGHUP, only on clean exit or proper shutdown.
This means any shell plugin or program that relies on exit handlers for cleanup will leave orphaned state behind.
Concrete example
Tide prompt creates per-PID universal variables (_tide_prompt_$PID) for async prompt rendering. The cleanup handler _tide_on_fish_exit removes these on exit. With tmux-resurrect/continuum, these handlers never fire.
After months of usage:
- 665 orphaned
_tide_prompt_*universal variables accumulated ~/.config/fish/fish_variablesgrew to 735KB- Prompt rendering broke entirely (empty content, only connection dots visible)
Filed upstream: IlanCosman/tide#636
Root cause
tmux kill-server -> SIGHUP -> fish terminates without running fish_exit handlers
This also affects vim (orphaned .swp files, see #120, #228) and likely any program using exit hooks.
Possible improvements
- Document the limitation in README/wiki (that exit handlers won't run)
- Consider sending SIGTERM with a grace period before kill-server shuts down
- Provide a hook/script for pre-shutdown cleanup (similar to what @timblaktu built with systemd in What is the best way to close down a complex tmux session - after having saved? #120)
Workaround
For fish + Tide specifically, add startup cleanup to ~/.config/fish/config.fish:
for var in (set -U --names | string match '_tide_prompt_*')
set -l pid (string replace '_tide_prompt_' '' $var)
if test "$pid" != "$fish_pid"; and not kill -0 $pid 2>/dev/null
set -e $var
end
end