Skip to content

feat(wasix): report stdin/out/err as Unknown if it isnt a tty - #6857

Open
kilyanni wants to merge 3 commits into
mainfrom
isatty
Open

feat(wasix): report stdin/out/err as Unknown if it isnt a tty#6857
kilyanni wants to merge 3 commits into
mainfrom
isatty

Conversation

@kilyanni

@kilyanni kilyanni commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI lite review requested due to automatic review settings August 5, 2026 16:52
@kilyanni
kilyanni marked this pull request as ready for review August 5, 2026 16:52
@kilyanni
kilyanni requested a review from Arshia001 August 5, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fds 0/1/2 to return CharacterDevice only when the corresponding host stream is a TTY, otherwise Unknown.
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 via WasiFs::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 via WasiFs::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(),
                    )),

Comment thread lib/wasix/src/fs/mod.rs Outdated
@kilyanni
kilyanni force-pushed the isatty branch 2 times, most recently from 28530ba to aab84b2 Compare August 5, 2026 18:04
stdin: 1
stdout: 1
stderr: 1
stdin: 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Arshia001 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this breaks anything that's not directly connected to a host's TTY, including something like wasmer.sh's terminal emulation.

@kilyanni

kilyanni commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

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 --tty=on|off|auto?

@kilyanni
kilyanni requested a review from Arshia001 August 7, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants