Skip to content
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

Allow waitpid(-1, Process::WNOHANG) to be woken if a waitpid(pid) is #10787

Open
wants to merge 1 commit into
base: ruby_3_2
Choose a base branch
from

Conversation

KJTsanaktsidis
Copy link
Contributor

...pending

If two threads are running, with one calling waitpid(-1, Process::WNOHANG), and another calling waitpid($some_pid), and then
$some_other_pid exits, we would expect the waitpid(-1, Process::WNOHANG) call to retrieve that exit status. However, it cannot actually do so until $some_pid also exits.

This patch fixes the issue by calling do_waitpid unconditionally in waitpid_wait; this will ensure that a waitpid -1 actually reaps something (after first checking that no PID-directed call wants the process).

...pending

If two threads are running, with one calling waitpid(-1, Process::WNOHANG),
and another calling waitpid($some_pid), and then
$some_other_pid exits, we would expect the waitpid(-1,
Process::WNOHANG) call to retrieve that exit status. However, it
cannot actually do so until $some_pid _also_ exits.

This patch fixes the issue by calling do_waitpid unconditionally in
waitpid_wait; this will ensure that a waitpid -1 actually reaps
something (after first checking that no PID-directed call wants the
process).

[Bug #20490]
@KJTsanaktsidis KJTsanaktsidis force-pushed the ktsanaktsidis/fix_waitpid_nohang_neg branch from b41d4b8 to 1900d37 Compare May 18, 2024 02:33
@KJTsanaktsidis
Copy link
Contributor Author

argh, I have to guard waitpid_wait with conditional compilation now because waitpid_each is too. Fixing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants