fix: graceful SIGINT/SIGTERM signal handling + 22 tests#486
Merged
bradygaster merged 2 commits intobradygaster:devfrom Mar 22, 2026
Merged
fix: graceful SIGINT/SIGTERM signal handling + 22 tests#486bradygaster merged 2 commits intobradygaster:devfrom
bradygaster merged 2 commits intobradygaster:devfrom
Conversation
Collaborator
Author
|
@bradygaster — Critical fix: CLI had no signal handlers — Ctrl+C during shell/watch/serve could orphan child processes. 44 lines of code + 22 tests. Low risk, high impact. |
Add signal handlers to prevent orphaned processes when users press Ctrl+C during long-running CLI operations. Changes: - cli-entry.ts: Top-level safety-net handler with 3s cleanup timeout and double-signal force-exit (130 for SIGINT, 143 for SIGTERM) - shell/index.ts: Shell-specific handler that calls Ink's unmount() to trigger the existing cleanup path (session close, client disconnect, telemetry shutdown), then exits with signal code Follows existing repo patterns (aspire.ts, watch.ts, rc.ts). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests for SIGINT/SIGTERM handlers added in previous commit: - Exit code verification (130 for SIGINT, 143 for SIGTERM) - Double-signal force-exit behavior - 3s cleanup timeout with unref - Handler registration validation - Shell-specific unmount flow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c04ab63 to
0571d45
Compare
bradygaster
approved these changes
Mar 22, 2026
Owner
bradygaster
left a comment
There was a problem hiding this comment.
EECOM review: Signal handling fix looks solid. Top-level safety net + shell-specific unmount path are both well-structured. 22 new tests cover exit codes, double-signal force-exit, cleanup timeout, and handler registration. Rebased on dev (includes #483 timeout fix + #480 race fix). CI failure was pre-existing platform-adapter timeouts — now resolved by the rebase.
chrislomonico
pushed a commit
to clomonico/squad
that referenced
this pull request
Mar 26, 2026
…dygaster#486) Add E2E journey test covering session persistence across shell restarts: - Session-store unit tests (create, save, load, list, 24h expiry, rehydration) - /sessions command integration (empty state, listing with counts) - /resume command integration (usage hint, unknown ID, prefix match) - Full day-1/day-2 journey: save on exit, detect on return, resume with history Closes bradygaster#398 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
fix: graceful SIGINT/SIGTERM signal handling
Adds signal handlers to prevent orphaned processes when users press Ctrl+C.
Problem
The CLI had no signal handlers. Pressing Ctrl+C during long operations (shell sessions, watch mode, remote bridge) could leave child processes running indefinitely.
Changes
3 files, 379 lines added:
packages/squad-cli/src/cli-entry.ts— Top-level safety net handlerunref'd so it doesn't block exit)packages/squad-cli/src/cli/shell/index.ts— Shell-specific handlerunmount()to flow through existing cleanup (session close, client disconnect, telemetry shutdown)test/cli/signal-handling.test.ts— 22 testsunref()Risk
Low. Only adds behavior on signal — doesn't change any existing code paths. Follows existing patterns in the repo. Build passes clean.