Skip to content

Commit

Permalink
use fcntl fallback for additional poll-specific errors
Browse files Browse the repository at this point in the history
  • Loading branch information
the8472 committed Jun 9, 2022
1 parent d3465a8 commit 2e62fda
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions library/std/src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
];

while libc::poll(pfds.as_mut_ptr(), 3, 0) == -1 {
if errno() == libc::EINTR {
continue;
}
if errno() == libc::EINVAL {
// RLIMIT_NOFILE may be preventing use of poll()
break 'poll;
match errno() {
libc::EINTR => continue,
libc::EINVAL | libc::EAGAIN | libc::ENOMEM => {
// RLIMIT_NOFILE or temporary allocation failures
// may be preventing use of poll(), fall back to fcntl
break 'poll;
}
_ => libc::abort(),
}
libc::abort();
}
for pfd in pfds {
if pfd.revents & libc::POLLNVAL == 0 {
Expand Down

0 comments on commit 2e62fda

Please sign in to comment.