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

#1796 in Command line utilities

Download history 365/week @ 2023-12-10 435/week @ 2023-12-17 426/week @ 2023-12-24 265/week @ 2023-12-31 130/week @ 2024-01-07 141/week @ 2024-01-14 91/week @ 2024-01-21 53/week @ 2024-01-28 183/week @ 2024-02-04 110/week @ 2024-02-11 113/week @ 2024-02-18 231/week @ 2024-02-25 227/week @ 2024-03-03 115/week @ 2024-03-10 195/week @ 2024-03-17 115/week @ 2024-03-24

694 downloads per month
Used in 6 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

~42KB