#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

#1352 in Command line utilities

Download history 220/week @ 2024-01-03 150/week @ 2024-01-10 155/week @ 2024-01-17 41/week @ 2024-01-24 157/week @ 2024-01-31 136/week @ 2024-02-07 64/week @ 2024-02-14 156/week @ 2024-02-21 274/week @ 2024-02-28 148/week @ 2024-03-06 142/week @ 2024-03-13 188/week @ 2024-03-20 245/week @ 2024-03-27 3443/week @ 2024-04-03 2444/week @ 2024-04-10 1652/week @ 2024-04-17

7,805 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