From 1b8c0d4222fd1f83c58a1fff07294f1b19584e21 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 26 Aug 2022 10:15:47 -0700 Subject: [PATCH] helix-term: properly handle libc::kill's failure I misread the manpage for POSIX `kill` -- it returns `-1` in the failure case, and sets `errno`, which is retrieved via `std::io::Error::last_os_error()`, has its string representation printed out, and then exits with the matching status code (or 1 if, for whatever reason, there is no matching status code). --- helix-term/src/application.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 709430f9abb91..284aec056561a 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -398,7 +398,9 @@ impl Application { }; if res != 0 { - eprintln!("{}", std::io::Error::from_raw_os_error(res)); + let err = std::io::Error::last_os_error(); + eprintln!("{}", err); + let res = err.raw_os_error().unwrap_or(1); std::process::exit(res); } }