From ca2aef33263b5caba25cc42e13976bc09a7d6220 Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Fri, 20 Oct 2023 10:05:09 +0300 Subject: [PATCH] query: suppress broken pipe error --- Cargo.lock | 1 + query/Cargo.toml | 1 + query/src/main.rs | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a6d3bd0..8c4624b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,6 +510,7 @@ name = "xash3d-query" version = "0.1.0" dependencies = [ "getopts", + "libc", "serde", "serde_json", "termion", diff --git a/query/Cargo.toml b/query/Cargo.toml index 8d02c50..e1ec87e 100644 --- a/query/Cargo.toml +++ b/query/Cargo.toml @@ -11,6 +11,7 @@ default = ["color"] color = ["termion"] [dependencies] +libc = "0.2.148" thiserror = "1.0.49" getopts = "0.2.21" serde = { version = "1.0.188", features = ["derive"] } diff --git a/query/src/main.rs b/query/src/main.rs index f986f30..7989917 100644 --- a/query/src/main.rs +++ b/query/src/main.rs @@ -558,6 +558,11 @@ fn execute(cli: Cli) -> Result<(), Error> { fn main() { let cli = cli::parse(); + // suppress broken pipe error + unsafe { + libc::signal(libc::SIGPIPE, libc::SIG_DFL); + } + if let Err(e) = execute(cli) { eprintln!("error: {}", e); process::exit(1);