fix(rocm): reset SIGPIPE so --dry-run doesn't panic (rc=101) - #185
Open
fredespi wants to merge 1 commit into
Open
fix(rocm): reset SIGPIPE so --dry-run doesn't panic (rc=101)#185fredespi wants to merge 1 commit into
fredespi wants to merge 1 commit into
Conversation
Rust installs SIG_IGN for SIGPIPE at startup, so when a downstream reader closes the pipe early (e.g. `rocm fix … --dry-run | head`) the next println! panics with "failed printing to stdout: Broken pipe" and exits 101. Reset SIGPIPE to SIG_DFL at the top of main() (the ripgrep/fd pattern) so the process terminates on the signal like a conventional Unix CLI. Socket writes are unaffected: std uses MSG_NOSIGNAL, so serve/daemon paths still get a normal BrokenPipe error. Adds a regression test that closes stdout early on a large-output command and asserts no panic / not exit 101.
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.
Summary
rocm fix fix-2-unset-override --dry-runpanicked with rc=101 when its output was piped — a dry-run should never panic. Rust ignores SIGPIPE by default and converts a broken pipe into a panic; this resets the SIGPIPE handler to default so piped output terminates cleanly.Changes
SIG_DFLat startup so a closed pipe exits normally (repro now exits 141, not a 101 panic).Test plan
... --dry-run | head) no longer panics — exits 141.