Skip to content

Commit

Permalink
Do not panic on poll() errors, and ignore EINTR
Browse files Browse the repository at this point in the history
  • Loading branch information
yyogo committed Feb 21, 2023
1 parent 4e880a5 commit 2f58255
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/event/source/unix/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,19 @@ 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 2f58255

Please sign in to comment.