Repository navigation
Stop a displaced PTY with SIGHUP so an interactive bash actually exits - #1070
Merged
Merged
Conversation
An interactive bash ignores SIGTERM, and once a spawn replaces a live generation in `ptys`, nothing can reach the old one again. The graceful stop therefore left the displaced shell running until the app exited. Stop it with node-pty's default kill() (SIGHUP on POSIX).
Deploying mouseterm with
|
| Latest commit: |
6468acf
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1e58dc59.mouseterm.pages.dev |
| Branch Preview URL: | https://fix-stop-displaced-pty-sighu.mouseterm.pages.dev |
nedtwigg
requested a deployment
to
hosted-preview
October 8, 2026 20:47 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a spawn lands on a PTY id that still has a live shell,
pty-corereplaces it and stops the old one, a behavior added in #1050. On macOS and Linux it stopped the old shell with the gracefulSIGTERM, but an interactive bash ignoresSIGTERMwhen it has no trap. The old generation is no longer inptys, sokill,killAll, andgracefulKillcan never reach it again, and the shell kept running until the app exited. That is the leak the stop was meant to prevent, and it contradictsdocs/specs/transport.md: "a spawn over a live generation stops the displaced one".This change stops the displaced PTY with node-pty's argument-less
kill()instead, which sendsSIGHUPon POSIX. Windows behavior is unchanged, sincestopPtyalready ignores the signal there. The quit path'sgracefulKillkeepsSIGTERM, as the transport spec's "Graceful shutdown" section requires; Rust's process-group kill follows it.The existing test in
standalone/sidecar/pty-core.test.jspinned['SIGTERM']and now expects the default signal. It fails before the fix and passes after it, and the whole file passes (127 tests). The test never runs a real shell. I checked the shell's side directly:bash -iunder a Pythonpty.fork()was still alive one second afterSIGTERMand exited afterSIGHUP.