Skip to content

wasix: report stdin fd type in fd_fdstat_get from actual fd kind - #6699

Open
Whadup wants to merge 1 commit into
wasmerio:mainfrom
Whadup:fix-wasix-stdin-fdstat-filetype
Open

wasix: report stdin fd type in fd_fdstat_get from actual fd kind#6699
Whadup wants to merge 1 commit into
wasmerio:mainfrom
Whadup:fix-wasix-stdin-fdstat-filetype

Conversation

@Whadup

@Whadup Whadup commented Jun 11, 2026

Copy link
Copy Markdown

Summary

  • fix for to derive from the actual fd inode kind when available
  • keep as the fallback when stdin cannot be resolved
  • add a WASIX stdio regression test in that verifies reports regular-file semantics for piped stdin

Why

  • When stdin is piped/scripted, hardcoding causes runtimes and tools to treat stdin as interactive TTY-like input, which breaks non-interactive script execution paths.

@marxin
marxin requested review from Arshia001 and theduke and removed request for Arshia001 June 11, 2026 07:23
@marxin marxin added the wasix label Jun 11, 2026
@theduke
theduke requested review from Arshia001 and Copilot June 16, 2026 04:51

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 aims to improve WASIX stdio metadata by having fd_fdstat_get report stdin’s fs_filetype based on the resolved FD/inode kind (instead of always CharacterDevice), and adds a regression test to ensure piped stdin reports regular-file semantics.

Changes:

  • Update WasiFs::fdstat to compute stdin fs_filetype from the resolved FD’s inode kind, with a fallback to CharacterDevice.
  • Add a WASIX stdio regression test that asserts fd_fdstat_get(0, ...) reports RegularFile when stdin is piped.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/wasix/src/fs/mod.rs Changes stdin fdstat filetype reporting to be derived from resolved FD/inode kind rather than hardcoded.
lib/wasix/tests/stdio.rs Adds a regression test module and test that validates stdin piped behavior via fd_fdstat_get.

Comment thread lib/wasix/src/fs/mod.rs
Comment on lines +1830 to +1837
let fs_filetype = self
.get_fd(fd)
.ok()
.map(|fd| {
let guard = fd.inode.read();
match guard.deref() {
Kind::File { .. } | Kind::Buffer { .. } => Filetype::RegularFile,
Kind::Dir { .. } => Filetype::Directory,
Comment thread lib/wasix/tests/stdio.rs
Comment on lines +222 to +227
fn test_fd_fdstat_get_stdin_pipe_reports_regular_file() {
#[cfg(not(target_arch = "wasm32"))]
let runtime = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants