diff --git a/listen-lib/src/lib.rs b/listen-lib/src/lib.rs index 82ef807..b762513 100644 --- a/listen-lib/src/lib.rs +++ b/listen-lib/src/lib.rs @@ -73,10 +73,15 @@ impl Listener { fn listen(self, mut cb: impl FnMut(Vec)) { let (send, recv) = std::sync::mpsc::sync_channel(100); thread::spawn(move || { self._listen(send); }); + let mut signals = Signals::new(&[SIGINT]).unwrap(); loop { match recv.recv_timeout(std::time::Duration::new(1, 0)) { Ok(msg) => cb(msg), - Err(_) => break, + Err(_) => { + if signals.pending().count() > 0 { + break; + } + }, }; } }