| Crates.io | broken-pipe-kills |
| lib.rs | broken-pipe-kills |
| version | 0.2.0 |
| created_at | 2026-01-06 06:40:21.36275+00 |
| updated_at | 2026-01-06 06:42:03.380964+00 |
| description | Get rid of `failed printing to stdout: Broken pipe (os error 32)` panics by setting `SIGPIPE` to `SIG_DFL` before your `fn main()` runs. |
| homepage | https://github.com/Enselic/broken-pipe-kills |
| repository | https://github.com/Enselic/broken-pipe-kills |
| max_upload_size | |
| id | 2025251 |
| size | 4,114 |
Normally the Rust standard library code sets SIGPIPE to SIG_IGN before your fn main() runs. This makes you see an error if you pipe your output to something like head:
fn main() {
loop {
println!("hello world");
}
}
$ ./main | head
hello world
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrac
Add the following to your Cargo.toml to set SIGPIPE to SIG_DFL instead so your program is nicely killed instead of panicking:
[dependencies]
broken-pipe-kills = "0.2.0"
$ ./main | head
hello world
Follow Tracking Issue for Externally Implementable Item #[std::io::on_broken_pipe] #150588 for updates.