File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,12 +17,9 @@ use std::panic::{self, PanicHookInfo};
1717
1818/// Decide whether a panic was caused by a broken pipe (SIGPIPE) error.
1919fn is_broken_pipe ( info : & PanicHookInfo ) -> bool {
20- if let Some ( res) = info. payload ( ) . downcast_ref :: < String > ( ) {
21- if res. contains ( "BrokenPipe" ) || res. contains ( "Broken pipe" ) {
22- return true ;
23- }
24- }
25- false
20+ info. payload ( )
21+ . downcast_ref :: < String > ( )
22+ . is_some_and ( |res| res. contains ( "BrokenPipe" ) || res. contains ( "Broken pipe" ) )
2623}
2724
2825/// Terminate without error on panics that occur due to broken pipe errors.
@@ -55,14 +52,12 @@ pub fn preserve_inherited_sigpipe() {
5552 use nix:: libc;
5653
5754 // Check if parent specified that SIGPIPE should be default
58- if let Ok ( val) = std:: env:: var ( "RUST_SIGPIPE" ) {
59- if val == "default" {
60- unsafe {
61- libc:: signal ( libc:: SIGPIPE , libc:: SIG_DFL ) ;
62- // Remove the environment variable so child processes don't inherit it incorrectly
63- std:: env:: remove_var ( "RUST_SIGPIPE" ) ;
64- }
65- }
55+ if let Ok ( val) = std:: env:: var ( "RUST_SIGPIPE" )
56+ && val == "default"
57+ {
58+ unsafe { libc:: signal ( libc:: SIGPIPE , libc:: SIG_DFL ) } ;
59+ // Remove the environment variable so child processes don't inherit it incorrectly
60+ unsafe { std:: env:: remove_var ( "RUST_SIGPIPE" ) } ;
6661 }
6762}
6863
You can’t perform that action at this time.
0 commit comments