aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-08-01 00:16:08 +0000
committerFuwn <[email protected]>2021-08-01 00:16:08 +0000
commitfc52e65c555f6dc3a0b43af04206095d3bfbbd51 (patch)
tree49ce504640d5a64a3a363fcfb230a46250b6e054
parentfix(whirl_prompt): clippy warnings (diff)
downloadwhirl-fc52e65c555f6dc3a0b43af04206095d3bfbbd51.tar.xz
whirl-fc52e65c555f6dc3a0b43af04206095d3bfbbd51.zip
fix(whirl): signal handling not working
-rw-r--r--crates/whirl/Cargo.toml1
-rw-r--r--crates/whirl/src/lib.rs17
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/whirl/Cargo.toml b/crates/whirl/Cargo.toml
index 156c22f..d927fb4 100644
--- a/crates/whirl/Cargo.toml
+++ b/crates/whirl/Cargo.toml
@@ -66,4 +66,3 @@ jemallocator = "0.3.2"
# Signal
signal-hook = "0.3.9"
-signal-hook-tokio = "0.3.0"
diff --git a/crates/whirl/src/lib.rs b/crates/whirl/src/lib.rs
index 6a0774b..0233b20 100644
--- a/crates/whirl/src/lib.rs
+++ b/crates/whirl/src/lib.rs
@@ -40,8 +40,6 @@ pub mod cli;
#[cfg(unix)]
use signal_hook::consts::signal::{SIGINT, SIGTERM};
-#[cfg(unix)]
-use tokio_stream::StreamExt;
use whirl_config::Config;
pub struct Whirl;
@@ -84,14 +82,13 @@ impl Whirl {
// Ctrl+C handling
#[cfg(unix)]
- tokio::spawn({
- while let Some(signal) = signal_hook_tokio::Signals::new(&[SIGTERM, SIGINT]).fuse() {
- match signal {
- _ => {
- info!("signal received: {:?}, killing whirl", signal);
- std::process::exit(0);
- }
- }
+ tokio::spawn(async move {
+ for signal in signal_hook::iterator::Signals::new(&[SIGTERM, SIGINT])
+ .unwrap()
+ .forever()
+ {
+ info!("signal received: {:?}, killing whirl", signal);
+ std::process::exit(0);
}
});