From 8aa7288db4e947849fe614cef9bac61c17a1c47a Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Tue, 4 Jun 2019 13:10:43 -0400 Subject: [PATCH] Fix ChildProcess::Unix::Process#wait method with leader processes 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. --- lib/childprocess/unix/process.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/childprocess/unix/process.rb b/lib/childprocess/unix/process.rb index bae5ecd..5b72a59 100644 --- a/lib/childprocess/unix/process.rb +++ b/lib/childprocess/unix/process.rb @@ -50,7 +50,8 @@ def wait if exited? exit_code else - _, status = ::Process.waitpid2 _pid + _, status = ::Process.waitpid2(@pid) + set_exit_code(status) end end