Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates WASIX fdstat reporting for the standard file descriptors (stdin/stdout/stderr) so that applications can distinguish interactive (TTY) I/O from non-interactive I/O.
Changes:
- Added a helper to map “is this stdio a TTY?” into a WASI
Filetype. - Updated
fdstat()for fds0/1/2to returnCharacterDeviceonly when the corresponding host stream is a TTY, otherwiseUnknown.
Suppressed comments (2)
lib/wasix/src/fs/mod.rs:1865
- The TTY detection for stdout is based on the host process’
std::io::stdout(), but fd 1 can be overridden viaWasiFs::swap_file. When stdout is swapped to a non-host stream,fdstat(1)should not consult the host TTY status.
fs_filetype: Self::std_fd_filetype(std::io::IsTerminal::is_terminal(
&std::io::stdout(),
)),
lib/wasix/src/fs/mod.rs:1875
- The TTY detection for stderr is based on the host process’
std::io::stderr(), but fd 2 can be overridden viaWasiFs::swap_file. When stderr is swapped to a non-host stream,fdstat(2)should not consult the host TTY status.
fs_filetype: Self::std_fd_filetype(std::io::IsTerminal::is_terminal(
&std::io::stderr(),
)),
28530ba to
aab84b2
Compare
| stdin: 1 | ||
| stdout: 1 | ||
| stderr: 1 | ||
| stdin: 0 |
There was a problem hiding this comment.
Having to change the wasi_fyi suite is a signal we're doing something wrong, since this test suite was created against the WASIp1 standard rather than our implementation of WASIX.
There was a problem hiding this comment.
Hm. The test suite asserts unconditionally that std* should be ttys. In our test-harness this is very likely not the case, so I'd expect this to be changed now.
Arshia001
left a comment
There was a problem hiding this comment.
I think this breaks anything that's not directly connected to a host's TTY, including something like wasmer.sh's terminal emulation.
|
But generally yeah, we should probably have some way to 'lie' to consumers that std* are TTYs even if they aren't with some (maybe on by default?) flag. Maybe |
This PR makes stdin/out/err report whether they're a tty or a file
Apps that check whether their IO is interactive need this in order to function properly