diff options
| author | Fuwn <[email protected]> | 2021-08-01 00:16:08 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-08-01 00:16:08 +0000 |
| commit | b034d4380b26e9641dcf8fbfeb30a1ad2a8c40d6 (patch) | |
| tree | e601963cf3a16e7d39aae721f6fe448093eb73bb | |
| parent | fix(whirl_prompt): clippy warnings (diff) | |
| download | whirl-b034d4380b26e9641dcf8fbfeb30a1ad2a8c40d6.tar.xz whirl-b034d4380b26e9641dcf8fbfeb30a1ad2a8c40d6.zip | |
fix(whirl): signal handling not working
| -rw-r--r-- | crates/whirl/Cargo.toml | 1 | ||||
| -rw-r--r-- | crates/whirl/src/lib.rs | 17 |
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/whirl/Cargo.toml b/crates/whirl/Cargo.toml index ac24853..265e007 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); } }); |