Skip to content

tmux kill-server workflow prevents shell exit handlers from running #559

@Marcel-Bich

Description

@Marcel-Bich

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_variables grew 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions