From 80f7f88532f565e931b4a28521e5cd67444a4d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20S=C3=A1lyi?= Date: Wed, 26 Apr 2023 20:52:19 +0200 Subject: [PATCH] Fix panic when the process is suspended In main event loop mio poll should immediately continue and retry on EINTR https://github.com/gergo-salyi/multibg-sway/issues/1 --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8534ef2..9b81add 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,7 +119,14 @@ fn main() event_queue.dispatch_pending(&mut state).unwrap(); let mut read_guard_option = Some(event_queue.prepare_read().unwrap()); - poll.poll(&mut events, None).unwrap(); + if let Err(poll_error) = poll.poll(&mut events, None) { + if poll_error.kind() == io::ErrorKind::Interrupted { + continue; + } + else { + panic!("Main event loop poll failed: {:?}", poll_error); + } + } for event in events.iter() { match event.token() {