Skip to content

Restore the cursor on SIGTERM - #9

Merged
dhh merged 1 commit into
omacom:masterfrom
yashranaway:fix/graceful-sigterm
Aug 11, 2026
Merged

Restore the cursor on SIGTERM#9
dhh merged 1 commit into
omacom:masterfrom
yashranaway:fix/graceful-sigterm

Conversation

@yashranaway

Copy link
Copy Markdown
Contributor

Restores the cursor when interactive ttfx receives SIGTERM and exits with status 143. Redirected output keeps the default SIGTERM behavior.

<<< AI wording below >>>>

Problem

SIGTERM normally exits immediately, bypassing terminal teardown and leaving the cursor hidden when ttfx is writing to a terminal.

Fix

Install a SIGTERM handler only when stdout is a tty, carry the signal through the normal run-loop cleanup, and return the conventional 128 + SIGTERM status (143). When stdout is redirected, keep the default signal action so the stream is not given extra teardown bytes.

Verification

  • Real pty: exit 143, one hide-cursor and one show-cursor.
  • Piped stdout: terminated by signal 15, no show-cursor teardown.
  • Effect parity: 354/354.
  • TTY byte-stream parity: 41/41.
  • CLI corpus: 19/19.

The default SIGTERM action exits immediately, bypassing terminal teardown and leaving an interactive cursor hidden. Install a handler only when stdout is a tty, carry the signal through the normal run-loop exit, and return the conventional 143 status after restoring the cursor.

Redirected output keeps the default signal behavior and receives no teardown bytes. Add a pty-driven regression covering both cases.
@dhh
dhh merged commit 5265881 into omacom:master Aug 11, 2026
3 checks passed
@yashranaway
yashranaway deleted the fix/graceful-sigterm branch August 12, 2026 07:04
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.

2 participants