Closed yamt closed 1 year ago
a small demo of the first problem. https://github.com/yamt/garbage/tree/master/wasm/stat
spacetanuki% ./test.sh
===== host cli
__wasi_fd_fdstat_get returned 0
fs_filetype 0
fs_rights_base 2
===== toywasm
__wasi_fd_fdstat_get returned 0
fs_filetype 2
fs_rights_base 0
===== wasmtime
__wasi_fd_fdstat_get returned 0
fs_filetype 2
fs_rights_base 8e001db
===== iwasm
__wasi_fd_fdstat_get returned 0
fs_filetype 2
fs_rights_base 820004a
spacetanuki%
the first problem confuses this isatty
: https://github.com/yamt/toywasm/blob/4a8f13cc0e315a0a2df91570cc70b6ea95fbac36/libwasi/wasi.c#L3296
the second problem was observed here: https://github.com/yamt/toywasm/blob/4a8f13cc0e315a0a2df91570cc70b6ea95fbac36/libwasi/wasi.c#L3309
when running an adapted preview1 commands with
host
cli,1. `fd_fdstat_get` says stdin etc are of `__WASI_FILETYPE_UNKNOWN` while i expected them being `__WASI_FILETYPE_CHARACTER_DEVICE`.
We're currently lacking a way to implement isatty
in preview2; once we add that, we can make the preview1 adapter call it and have fd_fdstat_get
set the type to __WASI_FILETYPE_CHARACTER_DEVICE
,
2. fcntl(F_SETFL) to set O_NONBLOCK on them on them fails.
It isn't implemented yet. It should be failing with ENOTSUP
for now.
when running an adapted preview1 commands with
host
cli,1. `fd_fdstat_get` says stdin etc are of `__WASI_FILETYPE_UNKNOWN` while i expected them being `__WASI_FILETYPE_CHARACTER_DEVICE`.
We're currently lacking a way to implement
isatty
in preview2; once we add that, we can make the preview1 adapter call it and havefd_fdstat_get
set the type to__WASI_FILETYPE_CHARACTER_DEVICE
,
ok. it makes sense.
2. fcntl(F_SETFL) to set O_NONBLOCK on them on them fails.
It isn't implemented yet. It should be failing with
ENOTSUP
for now.
it's actually EINVAL. (28) https://github.com/bytecodealliance/preview2-prototyping/issues/141#issuecomment-1510780527
Is this still an issue? I added support for setting O_NONBLOCK through the adapter in https://github.com/bytecodealliance/preview2-prototyping/pull/149/, though it doesn't actually do anything on the host side, I am going to work on that soon
I can have the adapter make stdio a character device instead of unknown, as long as that seems like its always the correct choice for the stdio streams, @sunfishcode agree?
@pchickey Use cases want isatty
to tell them whether they're talking to a terminal, which is useful to support, so we should make it reflect whether they're connected to a host terminal. I think we should add a function to WASI to provide that information.
Ok. I will send a PR that changes it to character device and we will hook that to stream isatty when its available, and have it be unknown if not.
when running an adapted preview1 commands with
host
cli,fd_fdstat_get
says stdin etc are of__WASI_FILETYPE_UNKNOWN
while i expected them being__WASI_FILETYPE_CHARACTER_DEVICE
.