Handle SIGPIPE (#5444)

This commit is contained in:
wznmickey 2024-11-29 04:21:19 -05:00 committed by GitHub
parent 9ce40cb91f
commit 3ab131c22c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 0 deletions

10
Cargo.lock generated
View File

@ -2245,6 +2245,15 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "sigpipe"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5584bfb3e0d348139d8210285e39f6d2f8a1902ac06de343e06357d1d763d8e6"
dependencies = [
"libc",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
@ -2705,6 +2714,7 @@ dependencies = [
"serde_json",
"serde_yaml 0.9.34+deprecated",
"shell-escape",
"sigpipe",
"tar",
"tempfile",
"toml",

View File

@ -104,6 +104,7 @@ serde = { version = "1.0.184", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9"
shell-escape = "0.1.5"
sigpipe = "0.1"
siphasher = "1"
smallvec = { version = "1.11.1", features = ["union", "const_generics", "const_new"] }
stacker = "0.1.15"

View File

@ -46,6 +46,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
shell-escape = { workspace = true }
sigpipe = { workspace = true }
tar = { workspace = true }
tempfile = { workspace = true }
toml = { workspace = true }

View File

@ -44,6 +44,10 @@ static ARGS: LazyLock<CliArguments> = LazyLock::new(|| {
/// Entry point.
fn main() -> ExitCode {
// Handle SIGPIPE
// https://stackoverflow.com/questions/65755853/simple-word-count-rust-program-outputs-valid-stdout-but-panicks-when-piped-to-he/65760807
sigpipe::reset();
let res = dispatch();
if let Err(msg) = res {