-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
introduce std.io.poll #14744
introduce std.io.poll #14744
Conversation
It's not OK to half-ass this function. Please implement it correctly, or not at all.
I think having inputs is problematic here, it should only be for outputs.
You can consider using |
No, nobody should use select for anything. See the warning right at the top of the linux man page:
|
Just FYI, Windows uses a different ABI for |
That sounds pretty much like https://github.com/ziglang/zig/pull/14152/files#diff-e0931af874560c650fde2b1a0f92b99f2d32edb04a823cf99b6161f69f5997eaR1552-R1562 except for a socket instead of pipe. |
Here's the initial windows implementation: marler8997@82ff9da |
Would be nice to have the additional test, but I think this is safe to merge given how much test coverage it gets from the build system. Thanks @marler8997! |
Motivation
I need the logic from
std.ChildProcess.collectOutput
for some other work I'm doing in #14647. This is my attempt to extract it into a reusable abstraction. In short summary, the usage looks like this:Each stream gets a
std.fifo.LinearFifo
which can be accessed by e.g.poller.fifo(.stdout)
. You can do this inside the while loop, or you can just let it accumulate as I have done above.Testing
Here is the code I used to test this. Before merging this PR I will break it up into parent.zig and child.zig and move it to be a standalone test.
Merge Checklist
std.ChildProcess.collectOutput
to use this abstraction. Most of that code can be deleted in theory, just need to add logic to limit tomax_output_bytes
.