Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Process.waitpid2
(?::Integer pid, ?::Integer flags) -> [ ::Integer, ::Process::Status ]
Process.wait2(pid = -1, flags = 0) → [pid, status]
process.c
View on GitHub ↗
static VALUE
proc_wait2(int argc, VALUE *argv, VALUE _)
{
VALUE pid = proc_wait(argc, argv);
if (NIL_P(pid)) return Qnil;
return rb_assoc_new(pid, rb_last_status_get());
}
Like Process.waitpid, but returns an array containing the child process pid and Process::Status status:
Example
pid = Process.spawn('ruby', '-e', 'exit 13') # => 309581 Process.wait2(pid) # => [309581, #<Process::Status: pid 309581 exit 13>]
Process.waitpid2 is an alias for Process.wait2.