diff options
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs index 900ad261f..985bf68dd 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1226,6 +1226,16 @@ fn get_subcommand( } } +fn setup_exit_process_panic_hook() { + // tokio does not exit the process when a task panics, so we + // define a custom panic hook to implement this behaviour + let orig_hook = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |panic_info| { + orig_hook(panic_info); + std::process::exit(1); + })); +} + fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T { match result { Ok(value) => value, @@ -1237,6 +1247,7 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T { } pub fn main() { + setup_exit_process_panic_hook(); #[cfg(windows)] colors::enable_ansi(); // For Windows 10 unix_util::raise_fd_limit(); |