Crates.io | sigpipe |
lib.rs | sigpipe |
version | 0.1.3 |
source | src |
created_at | 2022-02-02 01:57:13.801164 |
updated_at | 2022-02-02 02:26:15.786617 |
description | A single function call to reset SIGPIPE and fix `failed printing to stdout` |
homepage | |
repository | https://www.github.com/kurtbuilds/sigpipe |
max_upload_size | |
id | 525514 |
size | 5,940 |
The default Rust runtime panics when println!
and family write to a closed
pipe. sigpipe
fixes it with a single function call invoked at the start of your program.
fn main() {
sigpipe::reset();
// The rest of your program goes here.
}
# Using cargo-edit
cargo add sigpipe
# In your Cargo.toml
[dependencies]
sigpipe = "0.1"
There have been several discussions about this issue. See:
This library is directly copied from @burntsushi's StackOverflow answer.
I made this library to package the solution, so users don't have to hunt for it online.