#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

#1416 in Command line utilities

Download history 4603/week @ 2024-09-24 3235/week @ 2024-10-01 3658/week @ 2024-10-08 2540/week @ 2024-10-15 1859/week @ 2024-10-22 3088/week @ 2024-10-29 2440/week @ 2024-11-05 2943/week @ 2024-11-12 2460/week @ 2024-11-19 2361/week @ 2024-11-26 2020/week @ 2024-12-03 2301/week @ 2024-12-10 2682/week @ 2024-12-17 812/week @ 2024-12-24 1170/week @ 2024-12-31 2059/week @ 2025-01-07

7,088 downloads per month
Used in 8 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