hive-forge: die by SIGPIPE like every other CLI in a pipeline

Rust's runtime sets SIGPIPE to SIG_IGN at startup, so writing to a pipe
whose reader has gone away returns EPIPE and println! panics. `hive-forge
<verb> | head` printed a panic and exited 101 where cat, grep and every
other pipeline member exit quietly.

101 is not cosmetic: to a caller running `set -o pipefail` it is a real
failure, so a shell script that pipes our output stops on a condition
that is not an error.

Restore SIG_DFL first thing in main, before any output. Measured against
the same command: piped to head, 141 (killed by the signal) with empty
stderr; unpiped, 0; the pre-change binary, 101 with a panic.

Closes #3972
This commit is contained in:
atlas 2026-09-02 17:14:18 +02:00 committed by mara
commit e0c2f1aeaa
3 changed files with 25 additions and 0 deletions

View file

@ -38,6 +38,9 @@ reqwest = { workspace = true, features = [
] }
serde = { workspace = true }
serde_json = { workspace = true }
# Only for restoring the default SIGPIPE disposition at startup — see
# `restore_sigpipe` in src/main.rs. std has no safe API for it.
libc = { workspace = true }
[lints]
workspace = true