Skip to content

Commit

Permalink
Fix unnecessary explicit panic in PTY
Browse files Browse the repository at this point in the history
Closes #7680.
  • Loading branch information
ConradIrwin authored and chrisduerr committed Mar 19, 2024
1 parent 0ae2673 commit 066fe5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion alacritty/src/window_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 12 additions & 7 deletions alacritty_terminal/src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,19 @@ 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),
terminal,
event_proxy,
hold,
ref_test,
}
})
}

pub fn channel(&self) -> EventLoopSender {
Expand Down Expand Up @@ -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());
Expand All @@ -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;
},
}
}

Expand Down

0 comments on commit 066fe5e

Please sign in to comment.