bytecodealliance / rustix

Safe Rust bindings to POSIX-ish APIs
Other
1.5k stars 161 forks source link

waitpid doesn't returned pid #989

Open SUPERCILEX opened 10 months ago

SUPERCILEX commented 10 months ago

Is there a reason for this? It should return a (Pid, WaitStatus) so you can spawn multiple processes in parallel and wait for them to finish in any order while performing specific actions on a process' completion.

SUPERCILEX commented 10 months ago

wait kind of counts, but doesn't have the same semantics because it will wait for any children rather than just the ones in the same process group.

sunfishcode commented 10 months ago

No, this appears to just be an oversight. The original waitpid API in rustix didn't support waiting on process groups so the pid return value was redundant, but it now does support waiting in process groups, so it should return the pid.

SUPERCILEX commented 10 months ago

Cool! Should I submit a PR or does this go into the 1.0 issue? Not sure how you're managing breaking changes...

sunfishcode commented 10 months ago

You can submit breaking changes to the 1.0-staging branch. I'm going to start working toward a 1.0 release in order to fix #917 / #990, though there are a few things to do, so I don't yet have a timeline in mind.

If you'd like to do something that could be released sooner, we could add a new function named something like waitpid_pid or so, which returns the pid.