#signal #stdout #println #broken-pipe

sigpipe

A single function call to reset SIGPIPE and fix failed printing to stdout

3 releases

0.1.3 Feb 2, 2022
0.1.2 Feb 2, 2022
0.1.1 Feb 2, 2022

#1323 in Command line utilities

Download history 112/week @ 2024-03-25 2610/week @ 2024-04-01 2724/week @ 2024-04-08 2167/week @ 2024-04-15 2191/week @ 2024-04-22 1906/week @ 2024-04-29 1966/week @ 2024-05-06 2899/week @ 2024-05-13 2015/week @ 2024-05-20 2011/week @ 2024-05-27 1447/week @ 2024-06-03 1702/week @ 2024-06-10 2378/week @ 2024-06-17 2602/week @ 2024-06-24 1945/week @ 2024-07-01 2985/week @ 2024-07-08

9,965 downloads per month
Used in 7 crates

MIT license

4KB

GitHub Contributors Stars Build Status Downloads Crates.io

sigpipe

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.

Usage


fn main() {
    sigpipe::reset();
    // The rest of your program goes here.
}

Installation

# Using cargo-edit
cargo add sigpipe

# In your Cargo.toml
[dependencies]
sigpipe = "0.1"

Discussion

There have been several discussions about this issue. See:

Acknowledgments

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.

Dependencies

~43KB