Skip to content

Orphaned _tide_prompt_* universal variables accumulate when fish is killed without clean exit #636

@Marcel-Bich

Description

@Marcel-Bich

Problem

When fish shells are terminated without a clean exit (e.g., SIGHUP from tmux kill-server), the _tide_on_fish_exit cleanup handler never runs. This causes _tide_prompt_$PID universal variables to accumulate indefinitely in ~/.config/fish/fish_variables.

How to reproduce

  1. Use Tide with tmux-resurrect or tmux-continuum
  2. Let continuum auto-save/restore over time (or manually tmux kill-server + restore)
  3. Check: set -U --names | string match '_tide_prompt_*' | wc -l

Impact

On my system after months of tmux usage:

  • 665 orphaned _tide_prompt_* variables
  • fish_variables grew to 735KB
  • Prompt rendering broke: content was empty, only connection dots visible

Root cause

tmux kill-server sends SIGHUP. Fish terminates on SIGHUP but does not fire fish_exit event handlers. _tide_on_fish_exit never cleans up the universal variables for that PID.

This is not limited to tmux -- any non-clean fish termination (kill, crash, OOM) will cause the same accumulation.

Proposed fix

Add startup cleanup to _tide_init.fish (runs on every interactive shell start):

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

Uses kill -0 to check if the PID is still alive -- safe for concurrent fish shells and background tmux sessions.

Prior discussion

This was proposed by @IlanCosman in #69 for v5 but never implemented:

"startup check that iterates over all _tide_prompt variables, checks the PID, and removes any that are dead"

Related: #562 (fish_variables constantly modified), #242 (universal vs global vars), #374 (fish_variables churn)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions