Skip to content

fix(tui): exit when the input terminal hangs up - #558

Merged
SaladDay merged 1 commit into
mainfrom
codex/issue555-terminal-hangup
Nov 12, 2026
Merged

SaladDay merged 1 commit into
mainfrom
codex/issue555-terminal-hangup

Conversation

@SaladDay

@SaladDay SaladDay commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

When a terminal proxy closes its PTY without delivering SIGHUP, Crossterm 0.29 can spin inside poll indefinitely. The TUI's input budget cannot interrupt that call, leaving cc-switch using a full CPU core.

Add a Unix TUI guard that observes terminal hangup without reading input. A confirmed hangup terminates the process with status 129, since the input thread may never unwind. Normal connected-terminal exits retain the existing terminal restoration. The guard is scoped to the TUI; dependencies and input parsing stay unchanged.

Fixes #555.

Validation:

  • The real-PTY regression test times out with the guard disabled and passes with it enabled, with SIGHUP ignored.
  • A connected-PTY test verifies Ctrl-C input, leaving the alternate screen, and restoring canonical mode and echo.
  • The Linux CI integration job passed, including both PTY tests. Local verification runs in isolated configuration directories on macOS.
  • 18 relevant tests passed (PTY regression, input reducer, terminal lifecycle and interactive-mode selection); cargo fmt --check passed.
  • Clippy is blocked by an existing reversed_empty_ranges error in unchanged home_chart.rs:806. Running the same check with only that lint allowed succeeds, with no warnings in the new files.

@SaladDay
SaladDay merged commit c6ae6fa into main Nov 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TUI 在终端挂断后进入死循环,持续占满一个 CPU 核心(100% busy loop after PTY hangup)

1 participant