From: Ian Jackson Date: Sun, 8 Aug 2021 00:33:03 +0000 (+0100) Subject: ipif: Do not grumble about ipif getting sigpipe, if we are quitting X-Git-Tag: hippotat/1.0.0~237 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=ceb9a34ac113484065b5bcbb1b6dccf263e1a42b;p=hippotat.git ipif: Do not grumble about ipif getting sigpipe, if we are quitting Signed-off-by: Ian Jackson --- diff --git a/src/ipif.rs b/src/ipif.rs index dbffb3a..a466a79 100644 --- a/src/ipif.rs +++ b/src/ipif.rs @@ -61,7 +61,20 @@ impl Ipif { Ok(Ok(Err(e))) => error!("{}ipif stderr read failed: {}", icd, e), Ok(Ok(Ok(()))) => { }, } - if ! st.success() { + + fn is_sigpipe(st: ExitStatus) -> bool { + #[cfg(unix)] { + use std::os::unix::process::ExitStatusExt; + const SIGPIPE: i32 = 13; + if st.code() == Some(SIGPIPE+128) { return true } + if st.signal() == Some(SIGPIPE) { return true } + } + false + } + if st.success() { + } else if is_sigpipe(st) { + debug!("{}ipif process got SIGPIPE: {}", icd, st); + } else { error!("{}ipif process failed: {}", icd, st); } } diff --git a/src/prelude.rs b/src/prelude.rs index c0516d2..beab58f 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -17,7 +17,7 @@ pub use std::mem; pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; pub use std::path::{Path, PathBuf}; pub use std::panic; -pub use std::process; +pub use std::process::{self, ExitStatus}; pub use std::pin::Pin; pub use std::str::{self, FromStr}; pub use std::sync::Arc;