Fix isatty in WASI. (#3696)
WASI doesn't have an `isatty` ioctl or syscall, so wasi-libc's `isatty` implementation uses the file descriptor type and rights to determine if the file descriptor is likely to be a tty. The real fix here will be to add an `isatty` call to WASI. But for now, have Wasmtime set the filetype and rights for file descriptors so that wasi-libc's `isatty` works as expected.
This commit is contained in:
@@ -180,6 +180,9 @@ impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
|
||||
async fn num_ready_bytes(&self) -> Result<u64, Error> {
|
||||
Ok(0)
|
||||
}
|
||||
fn isatty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
async fn readable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
}
|
||||
@@ -336,6 +339,9 @@ impl<W: Write + Any + Send + Sync> WasiFile for WritePipe<W> {
|
||||
async fn num_ready_bytes(&self) -> Result<u64, Error> {
|
||||
Ok(0)
|
||||
}
|
||||
fn isatty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
async fn readable(&self) -> Result<(), Error> {
|
||||
Err(Error::badf())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user