Repository navigation
fix: a stalled stdout reader can't block signal wind-down - #162
Merged
Merged
Conversation
With a stdout pipe that is open but never read and no --timeout, SIGTERM, SIGHUP and SIGINT left sel and the runner group alive. Run's event loop was parked in a blocking write(1) (readerWatch.Write -> format.EventLine -> run.event), so it never saw the cancelled context and never reaped the runner. Only a --timeout arms the backstop clock, so nothing bounded it. Arm a hard exit when a signal is received and the context carries no backstop clock: after ShutdownBudget + backstopGrace it kills running git children and the runner group (the cleanups the backstop already runs) and exits 130. The timer is released when the command's own wind-down finishes, so a reader that keeps reading still gets its interrupted summary last. Exit codes outside this path are unchanged: with --timeout the backstop still decides (8 for TERM/HUP, as before), a closed reader exits before the timer, and a wind-down that finishes inside the budget releases it. A runner that needs the whole 12 s budget sits 0.25 s inside the bound; only a 5.7 s wind-down is tested. Limits: the bound is absolute, so a reader slower than the bound is cut off like a stalled one; the cut-off run writes no final summary because stdout is the thing that is stuck. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
The timer started at the signal and hard-exited 130 when it fired, but the run's own wind-down cannot start until a blocked stdout write returns. A reader that resumed after 8 s, with a runner that ignores SIGINT, was cut off with no summary; the base commit delivered it. stdout writes are now counted (started, returned). At ShutdownBudget the timer samples the counters and, after backstopGrace, exits 130 only if a write is still in flight and none has returned since the signal. A recovered reader keeps winding down and gets its summary. A hard limit of 2*ShutdownBudget + backstopGrace from the signal still ends a reader that drips. wound is re-checked before any hard exit. A reader that never reads is cut at ShutdownBudget + backstopGrace, as before. Known edges: a wedge that is not a tracked stdout write (stalled stderr, the watch-mode idle line) now waits for the hard limit instead of the first timer. The wound re-check cannot be tested deterministically: it matters only when the hard limit and the close of wound are ready in the same instant. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
natevick
marked this pull request as ready for review
November 22, 2026 23:57
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.
After SIGTERM, SIGHUP or Ctrl-C, a stalled stdout reader can no longer leave
sel testand the runner alive forever.Linear: SEL-392.
What changed
--timeout, if a stdout write is still stuck about 12.25 seconds after the signal,selkills the runner group and exits 130.selopen.Checks
--watchand--timeout: match the base commit.go veton all three platforms,go test -race, and golangci-lint 1.64.8 pass.Behavior to know
Not established
🤖 Generated with Claude Code
https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp