#signal #stdout #println #panic #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

#1420 in Command line utilities

Download history 2482/week @ 2024-11-16 2147/week @ 2024-11-23 2253/week @ 2024-11-30 1974/week @ 2024-12-07 3009/week @ 2024-12-14 865/week @ 2024-12-21 754/week @ 2024-12-28 2553/week @ 2025-01-04 3013/week @ 2025-01-11 2282/week @ 2025-01-18 3057/week @ 2025-01-25 2911/week @ 2025-02-01 2800/week @ 2025-02-08 4695/week @ 2025-02-15 6454/week @ 2025-02-22 3781/week @ 2025-03-01

18,251 downloads per month
Used in 10 crates

MIT license

5KB

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