Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Process.waitpid2

Process.wait2(pid = -1, flags = 0) → [pid, status]

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.waitpid.

See also .waitpid .warmup .waitall also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0