diff options
-rw-r--r-- | alacritty/src/window_context.rs | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/event_loop.rs | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs index 3f3e6807..891551bb 100644 --- a/alacritty/src/window_context.rs +++ b/alacritty/src/window_context.rs @@ -223,7 +223,7 @@ impl WindowContext { pty, pty_config.hold, config.debug.ref_test, - ); + )?; // The event loop channel allows write requests from the event processor // to be sent to the pty loop and ultimately written to the pty. diff --git a/alacritty_terminal/src/event_loop.rs b/alacritty_terminal/src/event_loop.rs index 57045f4a..42025b00 100644 --- a/alacritty_terminal/src/event_loop.rs +++ b/alacritty_terminal/src/event_loop.rs @@ -67,10 +67,11 @@ where pty: T, hold: bool, ref_test: bool, - ) -> EventLoop<T, U> { + ) -> io::Result<EventLoop<T, U>> { let (tx, rx) = mpsc::channel(); - EventLoop { - poll: polling::Poller::new().expect("create Poll").into(), + let poll = polling::Poller::new()?.into(); + Ok(EventLoop { + poll, pty, tx, rx: PeekableReceiver::new(rx), @@ -78,7 +79,7 @@ where event_proxy, hold, ref_test, - } + }) } pub fn channel(&self) -> EventLoopSender { @@ -213,8 +214,9 @@ where let mut interest = PollingEvent::readable(0); // Register TTY through EventedRW interface. - unsafe { - self.pty.register(&self.poll, interest, poll_opts).unwrap(); + if let Err(err) = unsafe { self.pty.register(&self.poll, interest, poll_opts) } { + error!("Event loop registration error: {}", err); + return (self, state); } let mut events = Events::with_capacity(NonZeroUsize::new(1024).unwrap()); @@ -235,7 +237,10 @@ where if let Err(err) = self.poll.wait(&mut events, timeout) { match err.kind() { ErrorKind::Interrupted => continue, - _ => panic!("EventLoop polling error: {err:?}"), + _ => { + error!("Event loop polling error: {}", err); + break 'event_loop; + }, } } |