-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
test.rb:
pid = Process.spawn("sleep 3")
puts Process.waitpid(pid, Process::WNOHANG).nil?
sleep 6
puts Process.waitpid(pid, Process::WNOHANG).nil?Executing the script above with Ruby v2.2.2 produces the following output:
true
falseAnd executing it with JRuby v1.7.20 produces this:
false
Errno::ECHILD: No child processes - No child processes
waitpid at org/jruby/RubyProcess.java:536
waitpid at org/jruby/RubyProcess.java:521
(root) at test.rb:4It seems Process.waitpid returns zero instead of nil while the child process hasn't exited. Is this different behaviour known/expected?
If it is, what is the best way to check that a child process is still running and has not exited yet? Simply Process.waitpid(pid, Process::WNOHANG) == 0?
Reactions are currently unavailable