wait2(...)
public
Waits for a child process to exit
(see Process::waitpid for exact semantics) and returns an array containing
the process id and the exit status
(a Process::Status object) of that
child. Raises a SystemError if there are no child processes.
Process.fork { exit 99 }
pid, status = Process.wait2
pid
status.exitstatus
Show source
/*
* call-seq:
* Process.wait2(pid=-1, flags=0) => [pid, status]
* Process.waitpid2(pid=-1, flags=0) => [pid, status]
*
* Waits for a child process to exit (see Process::waitpid for exact
* semantics) and returns an array containing the process id and the
* exit status (a <code>Process::Status</code> object) of that
* child. Raises a <code>SystemError</code> if there are no child
* processes.
*
* Process.fork { exit 99 } #=> 27437
* pid, status = Process.wait2
* pid #=> 27437
* status.exitstatus #=> 99
*/
static VALUE
proc_wait2(argc, argv)
int argc;
VALUE *argv;
{
VALUE pid = proc_wait(argc, argv);
if (NIL_P(pid)) return Qnil;
return rb_assoc_new(pid, rb_last_status);
}