Skip to content

Commit

Permalink
Do not panic on poll() errors, and ignore EINTR (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyogo authored Feb 26, 2023
1 parent 4e880a5 commit e7fc698
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/event/source/unix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,20 @@ impl EventSource for UnixInternalEventSource {
return Ok(Some(event));
}
match poll(&mut fds, timeout.leftover()) {
Err(filedescriptor::Error::Io(e)) => return Err(e),
res => res.expect("polling tty"),
Err(filedescriptor::Error::Poll(e)) | Err(filedescriptor::Error::Io(e)) => {
match e.kind() {
// retry on EINTR
io::ErrorKind::Interrupted => continue,
_ => return Err(e),
}
}
Err(e) => {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("got unexpected error while polling: {:?}", e),
))
}
Ok(_) => (),
};
if fds[0].revents & POLLIN != 0 {
loop {
Expand Down

0 comments on commit e7fc698

Please sign in to comment.