Do not panic on poll() errors, and ignore EINTR (#762)

This commit is contained in:
Jonathan 2023-02-26 17:39:19 +02:00 committed by GitHub
parent 4e880a5c90
commit e7fc698f24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,8 +131,20 @@ impl EventSource for UnixInternalEventSource {
return Ok(Some(event)); return Ok(Some(event));
} }
match poll(&mut fds, timeout.leftover()) { match poll(&mut fds, timeout.leftover()) {
Err(filedescriptor::Error::Io(e)) => return Err(e), Err(filedescriptor::Error::Poll(e)) | Err(filedescriptor::Error::Io(e)) => {
res => res.expect("polling tty"), 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 { if fds[0].revents & POLLIN != 0 {
loop { loop {