Skip to content

Commit 592815f

Browse files
committed
Use a worker thread for stdin on Unix with preview2
Currently stdin on Unix uses `AsyncFd` after setting the nonblocking flag on the stdin file descriptor. This cannot generally be relied on to succeed or work well in cases such as: * On Linux if stdin is a file (e.g. `wasmtime < ./foo.txt`) then that can't be added to epoll and `epoll_ctl` fails with EPERM. * On macOS if stdin is `/dev/null` that can't be added to kqueue and fails with `EINVAL`. Currently this causes Wasmtime to panic due to a `.unwrap()` in failing to register stdin. To fix this this commit removes the Unix-specific logic using `AsyncFd` and instead falls back to unconditionally using a spawned thread like Windows does. This does mean it's a little less lightweight but should be more robust in situations like the above.
1 parent 215eb35 commit 592815f

2 files changed

Lines changed: 0 additions & 140 deletions

File tree

crates/wasi/src/preview2/stdio.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
use crate::preview2::pipe::AsyncWriteStream;
22

3-
#[cfg(unix)]
4-
mod unix;
5-
#[cfg(unix)]
6-
pub use self::unix::{stdin, Stdin};
7-
8-
#[allow(dead_code)]
93
mod worker_thread_stdin;
10-
#[cfg(windows)]
114
pub use self::worker_thread_stdin::{stdin, Stdin};
125

136
pub type Stdout = AsyncWriteStream;

crates/wasi/src/preview2/stdio/unix.rs

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)