Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Process::Status.wait

Process::Status.wait(pid = -1, flags = 0) → Process::Status

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. Unlike Process.wait, this method does not set thread-local variable $?:

Example
Process.spawn('cat /nop') # => 1155880
Process::Status.wait      # => #<Process::Status: pid 1155880 exit 1>
$?                        # => nil # Not set.

If there is no child process, returns an “empty” Process::Status object that does not represent an actual process:

Example
Process::Status.wait # => #<Process::Status: pid -1 exit 0>

May invoke the scheduler hook Fiber::Scheduler#process_wait.

Not available on all platforms.

See also #== #coredump? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0