From e9d5b2007a5b7cb70a514dad6812fbc22f2f619c Mon Sep 17 00:00:00 2001 From: mahkoh Date: Sat, 20 Nov 2021 01:24:45 +0100 Subject: [PATCH] On X11, don't panic when getting EINTR Fixes #1972. --- CHANGELOG.md | 1 + src/platform_impl/linux/x11/mod.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4be82eb8ba..17b69de36a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - On macOS, fix native file dialogs hanging the event loop. - On Wayland, implement a workaround for wrong configure size when using `xdg_decoration` in `kwin_wayland` - On macOS, fix an issue that prevented the menu bar from showing in borderless fullscreen mode. +- On X11, EINTR while polling for events no longer causes a panic. Instead it will be treated as a spurious wakeup. # 0.25.0 (2021-05-15) diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index c453ed56d4..3ea03b1eb8 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -360,7 +360,11 @@ impl EventLoop { // If the XConnection already contains buffered events, we don't // need to wait for data on the socket. if !self.event_processor.poll() { - self.poll.poll(&mut events, timeout).unwrap(); + if let Err(e) = self.poll.poll(&mut events, timeout) { + if e.raw_os_error() != Some(libc::EINTR) { + panic!("epoll returned an error: {:?}", e); + } + } events.clear(); }