// The standard streams might be closed on application startup. To prevent
// std::io::{stdin, stdout,stderr} objects from using other unrelated file
// resources opened later, we reopen standards streams when they are closed.
Rust does so, by first polling on the file descriptors. On EINVAL, EAGAIN, and ENOMEM, Rust falls back from using poll (std/src/sys/unix/mod.rs#L108-L118).
On Unikraft, with musl, this returns ENOSYS, though, resulting in an abort.
We could approach this issue from both Unikraft and Rust. We could either
Make poll on Unikraft return any of EINVAL, EAGAIN, or ENOMEM or
make Rust also fall back from using poll on ENOSYS.
I personally think, 2 would be the better option, though that somewhat conflicts with the idea that we should not have to adjust programs for running on Unikraft and instead fix the issue on our side.
On Linux, when the Rust runtime initializes, Rust sanitizes the standard streams: (
std/src/sys/unix/mod.rs#L54-L57
)Rust does so, by first
poll
ing on the file descriptors. OnEINVAL
,EAGAIN
, andENOMEM
, Rust falls back from usingpoll
(std/src/sys/unix/mod.rs#L108-L118
).On Unikraft, with musl, this returns
ENOSYS
, though, resulting in anabort
.C code for reproduction:
prints
We could approach this issue from both Unikraft and Rust. We could either
poll
on Unikraft return any ofEINVAL
,EAGAIN
, orENOMEM
orpoll
onENOSYS
.I personally think, 2 would be the better option, though that somewhat conflicts with the idea that we should not have to adjust programs for running on Unikraft and instead fix the issue on our side.
What do you think?