Method: Process.wait2

Defined in:
process.c

.wait2(pid = -1, flags = 0) ⇒ Array

Like Process.waitpid, but returns an array containing the child process pid and Process::Status status:

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.

Returns:



1487
1488
1489
1490
1491
1492
1493
# File 'process.c', line 1487

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());
}