Skip to content

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

class method

Process.waitpid2

(?::Integer pid, ?::Integer flags) -> [ ::Integer, ::Process::Status ]
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.wait2.

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