From 43e495ac6c6cbd8eb997135dc05e9ed7036489c0 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 20 Dec 2023 22:58:25 -0500 Subject: [PATCH] still broken looping in lib-rs but marginally better so --- listen-lib/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; + } + }, }; } }