Skip to content

Draft a prototype stdio design for wasip3. #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sunfishcode
Copy link
Member

There are still some FIXME comments in the code to resolve.

/// This function reads at most `amount` bytes from a
/// “standard input” source.
@since(version = 0.3.0)
read: func(amount: u32) -> result<list<u8>, error>;

Choose a reason for hiding this comment

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

shouldn't this be async so you can avoid blocking?

Copy link
Member Author

Choose a reason for hiding this comment

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

Async in Wit is just a hint, so you can avoid blocking either way, and the main question is what the default should be.

In my experience most programs that use stdin use it in a synchronous way, which suggests making it sync by default, but I don't have a strong opinion about it.

Copy link

@programmerjake programmerjake Jul 23, 2025

Choose a reason for hiding this comment

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

many C programs use functions like kbhit or O_NONBLOCK on stdin, imo we should have support in the C library for stuff like that, afaict that requires the C library to use the async version even if most programs just block.

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.

2 participants