-
Notifications
You must be signed in to change notification settings - Fork 79
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
waitpid blocking on leader processes in ruby 2.6 #151
Comments
Issue #151 reported a problem where in the update from Ruby 2.5 to Ruby 2.6 some programs would block forever on a `Process.waitpid2` call. Changing the call to pass in a positive PID instead of the negative PID fixes the issue as it will call the `waitpid` system call right away instead of delaying it for later. See #151 for further discussion of the possible reasons for the behavior.
Hey @jdelStrother, thanks for the report. To summarize:
I can reproduce your behavior on a Linux system (it raises I modified your program to print out the process ID and process group ID (PGID) along with process hierarchy, and changed the commands to make them easier to identify (changing Child 1 and 2 to be
I then ran this program on both Ruby 2.5 and Ruby 2.6: Ruby 2.5
Ruby 2.6
Notice that in both cases, Child 2 is in its own process group as expected. Killing Child 1 results in a This is all speculation, however. Ruby's The primary question we need to understand before we make the proposed change is whether it is semantically correct for |
Issue #151 reported a problem where in the update from Ruby 2.5 to Ruby 2.6 some programs would block forever on a `Process.waitpid2` call. Changing the call to pass in a positive PID instead of the negative PID fixes the issue as it will call the `waitpid` system call right away instead of delaying it for later. See #151 for further discussion of the possible reasons for the behavior.
Issue #151 reported a problem where in the update from Ruby 2.5 to Ruby 2.6 some programs would block forever on a `Process.waitpid2` call. Changing the call to pass in a positive PID instead of the negative PID fixes the issue as it will call the `waitpid` system call right away instead of delaying it for later. See #151 for further discussion of the possible reasons for the behavior.
Didn't receive any feedback in #152. Going to close this as it solves the issue as described and seems to achieve the same semantic behavior. |
I've run into a problem with waiting for leader-processes to exit, which only surfaces in convoluted circumstances.
If you want the details:
• Our test suite launches a long-lived background process which is supposed to stay running for the duration of the test suite. We call .wait on the process so we can tell if it exited early due to an error, but normally it'll be killed when we send TERM to it in the test suite's at_exit hook.
• We also launch chromedriver (via selenium). Selenium sets
leader=true
on the child process• When the test suite is done, selenium calls .stop on the chromedriver process.
• In ruby 2.6.3p62 (but not ruby 2.5.3p105),
childprocess.stop
blocks indefinitely, stuck in waitpid2 herechildprocess/lib/childprocess/unix/process.rb
Line 53 in 982b1ae
The problem reduces down to this script:
In theory, this ought to launch two child processes
child1
&child2
, stopchild2
, then stopchild1
in the at_exit handler. In ruby 2.6 though, it gets stuck atchild2.stop
.If we remove the
child1.wait
line, or if child2 isn't a leader,child2.stop
doesn't get blocked.Is it correct that for leader processes, childprocess passes the negative pid to waitpid2 ? Shouldn't the negative pid only be used for sending signals? Or is this a bug in ruby itself?
The text was updated successfully, but these errors were encountered: