Skip to content

fix(rocm): reset SIGPIPE so --dry-run doesn't panic (rc=101) - #185

Open
fredespi wants to merge 1 commit into
mainfrom
rocm-fix-fix-2-unset-override-dry-run-panics-rc
Open

fix(rocm): reset SIGPIPE so --dry-run doesn't panic (rc=101)#185
fredespi wants to merge 1 commit into
mainfrom
rocm-fix-fix-2-unset-override-dry-run-panics-rc

Conversation

@fredespi

@fredespi fredespi commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

rocm fix fix-2-unset-override --dry-run panicked 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

  • Reset SIGPIPE to SIG_DFL at startup so a closed pipe exits normally (repro now exits 141, not a 101 panic).
  • Added a regression test for the piped dry-run path.

Test plan

  • Repro (... --dry-run | head) no longer panics — exits 141.
  • Regression test passes; clippy + unit/lib tests green in the container.

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.
@fredespi
fredespi requested a review from a team as a code owner August 6, 2026 03:55
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.

1 participant