diff options
author | Conrad Irwin <conrad.irwin@gmail.com> | 2024-02-01 23:19:23 -0700 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2024-03-19 02:20:53 +0100 |
commit | 066fe5e3d85f5338b66d37b68df15d71cd655dc5 (patch) | |
tree | dd95b332785535acabfdbe311a03d38c24fc7ce6 | |
parent | 0ae2673682f59818766f37107ef565bc4342c328 (diff) | |
download | alacritty-066fe5e3d85f5338b66d37b68df15d71cd655dc5.tar.gz alacritty-066fe5e3d85f5338b66d37b68df15d71cd655dc5.zip |
Fix unnecessary explicit panic in PTY
Closes #7680.
-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; + }, } } |