chiark / gitweb /
ipif: Do not grumble about ipif getting sigpipe, if we are quitting
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Aug 2021 00:33:03 +0000 (01:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Aug 2021 00:33:03 +0000 (01:33 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/ipif.rs
src/prelude.rs

index dbffb3a1fbd6e34021039b7a9b3fa6615d65dc57..a466a790d47cfe286e26cb6f318282ae20254850 100644 (file)
@@ -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);
         }
       }
index c0516d28e88672a0efd2eb40f453dc555710551f..beab58f0786b168e42d13a8ed96f0a24c9eb9ca8 100644 (file)
@@ -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;