wasi-common: don't rely on platform dependent "NUL" device
If stdio is not inherited nor associated with a file, WasiCtxBuilder
tries to open "/dev/null" ("NUL" on Windows) and attach stdio to it.
While most platforms today support those device files, it would be
good to avoid unnecessary access to the host device if possible. This
patch instead uses a virtual Handle that emulates the "NUL" device.
This commit is contained in:
@@ -10,13 +10,6 @@ use std::fs::File;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::ops::Deref;
|
||||
|
||||
/// Extra methods for `OsOther` that are only available when configured for
|
||||
/// some operating systems.
|
||||
pub trait OsOtherExt {
|
||||
/// Create `OsOther` as `dyn Handle` from null device.
|
||||
fn from_null() -> io::Result<Box<dyn Handle>>;
|
||||
}
|
||||
|
||||
/// `OsOther` is something of a catch-all for everything not covered with the specific handle
|
||||
/// types (`OsFile`, `OsDir`, `Stdio`). It currently encapsulates handles such as OS pipes,
|
||||
/// sockets, streams, etc. As such, when redirecting stdio within `WasiCtxBuilder`, the redirected
|
||||
|
||||
Reference in New Issue
Block a user