query: suppress broken pipe error

This commit is contained in:
Denis Drakhnia 2023-10-20 10:05:09 +03:00
parent 62fe4d0b6c
commit ca2aef3326
3 changed files with 7 additions and 0 deletions

1
Cargo.lock generated
View File

@ -510,6 +510,7 @@ name = "xash3d-query"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"getopts", "getopts",
"libc",
"serde", "serde",
"serde_json", "serde_json",
"termion", "termion",

View File

@ -11,6 +11,7 @@ default = ["color"]
color = ["termion"] color = ["termion"]
[dependencies] [dependencies]
libc = "0.2.148"
thiserror = "1.0.49" thiserror = "1.0.49"
getopts = "0.2.21" getopts = "0.2.21"
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.188", features = ["derive"] }

View File

@ -558,6 +558,11 @@ fn execute(cli: Cli) -> Result<(), Error> {
fn main() { fn main() {
let cli = cli::parse(); let cli = cli::parse();
// suppress broken pipe error
unsafe {
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
}
if let Err(e) = execute(cli) { if let Err(e) = execute(cli) {
eprintln!("error: {}", e); eprintln!("error: {}", e);
process::exit(1); process::exit(1);