Skip to content

Makes the Rust standard library keep `SIGPIPE` as `SIG_DFL`.

License

Notifications You must be signed in to change notification settings

Enselic/sigpipe-default

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sigpipe-default

What is the problem?

Normally the Rust standard library code sets SIGPIPE to SIG_IGN before your fn main() runs. This makes you see an error if you pipe your output to something like head:

fn main() {
    loop {
        println!("hello world");
    }
}
$ ./main | head
hello world
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrac

How do I solve it?

Add the following to your Cargo.toml to keep SIGPIPE as SIG_DFL so your program is nicely killed instead of panicking:

[dependencies]
sigpipe-default = "0.1.0"
$ ./main | head
hello world

When Can I Use It?

Follow rust-lang/rust#150588 for updates.

About

Makes the Rust standard library keep `SIGPIPE` as `SIG_DFL`.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages