diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-02-04 01:14:46 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-10-01 18:57:52 +0300 |
commit | 6de5d6ddc75dd92aad9102192cefa73debe939d1 (patch) | |
tree | b5285dbc301e322d9d979eb7336ae33907218629 | |
parent | afccc17e8df178ab2ea3db80fbb020c0225a22fa (diff) |
Add SIGTERM handler
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 167e3fb..c103ee8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -153,13 +153,21 @@ fn notify( let _ = s.send(signal_hook::SIGINT); } }; - let sigquit_handler = move |_info: &nix::libc::siginfo_t| { + let sigquit_handler = { + let state = state.clone(); + move |_info: &nix::libc::siginfo_t| { + crate::state::restore_to_main_screen(state.clone()); + std::process::exit(131); + } + }; + let sigterm_handler = move |_info: &nix::libc::siginfo_t| { crate::state::restore_to_main_screen(state.clone()); - std::process::exit(131); + std::process::exit(143); }; unsafe { signal_hook_registry::register_sigaction(signal_hook::SIGINT, sigint_handler)?; signal_hook_registry::register_sigaction(signal_hook::SIGQUIT, sigquit_handler)?; + signal_hook_registry::register_sigaction(signal_hook::SIGTERM, sigterm_handler)?; } let signals = signal_hook::iterator::Signals::new(signals)?; std::thread::spawn(move || { |