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

(?::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 .wait .waitall .uid= .waitpid also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0