Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Process::Status.wait
Process::Status.wait(pid = -1, flags = 0) → Process::Status
process.c
View on GitHub ↗
static VALUE
rb_process_status_waitv(int argc, VALUE *argv, VALUE _)
{
rb_check_arity(argc, 0, 2);
rb_pid_t pid = -1;
int flags = 0;
if (argc >= 1) {
pid = NUM2PIDT(argv[0]);
}
if (argc >= 2) {
flags = RB_NUM2INT(argv[1]);
}
return rb_process_status_wait(pid, flags);
}
Like Process.wait, but returns a Process::Status object (instead of an integer pid or nil); see Process.wait for the values of pid and flags.
If there are child processes, waits for a child process to exit and returns a Process::Status object containing information on that process; sets thread-local variable $?:
Example
Process.spawn('cat /nop') # => 1155880 Process::Status.wait # => #<Process::Status: pid 1155880 exit 1> $? # => #<Process::Status: pid 1155508 exit 1>
If there is no child process, returns an “empty” Process::Status object that does not represent an actual process; does not set thread-local variable $?:
Example
Process::Status.wait # => #<Process::Status: pid -1 exit 0> $? # => #<Process::Status: pid 1155508 exit 1> # Unchanged.
May invoke the scheduler hook Fiber::Scheduler#process_wait.
Not available on all platforms.