From bfbcc9caa9fd6bcbb30548c515e05525c7fd6f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 5 Jul 2023 12:49:35 +0200 Subject: [PATCH] `unix::init`: Also fall back from `poll` on `ENOSYS` Operating systems like [Unikraft] may return [`ENOSYS`] (Function not implemented (POSIX.1-2001)) on certain syscalls. Falling back from using `poll` at runtime initialization allows starting Rust applications on such systems. [Unikraft]: https://unikraft.org/ [`ENOSYS`]: https://www.man7.org/linux/man-pages/man3/errno.3.html --- library/std/src/sys/unix/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 1b72e21a83285..502ab3a4a4b1b 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -109,7 +109,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { while libc::poll(pfds.as_mut_ptr(), 3, 0) == -1 { match errno() { libc::EINTR => continue, - libc::EINVAL | libc::EAGAIN | libc::ENOMEM => { + libc::ENOSYS | libc::EINVAL | libc::EAGAIN | libc::ENOMEM => { // RLIMIT_NOFILE or temporary allocation failures // may be preventing use of poll(), fall back to fcntl break 'poll;