Skip to content
class method

Process.last_status

Process.last_status → Process::Status or nil

Returns a Process::Status object representing the most recently exited child process in the current thread, or nil if none:

Example
Process.spawn('ruby', '-e', 'exit 13')
Process.wait
Process.last_status # => #<Process::Status: pid 14396 exit 13>

Process.spawn('ruby', '-e', 'exit 14')
Process.wait
Process.last_status # => #<Process::Status: pid 4692 exit 14>

Process.spawn('ruby', '-e', 'exit 15')
# 'exit 15' has not been reaped by #wait.
Process.last_status # => #<Process::Status: pid 4692 exit 14>
Process.wait
Process.last_status # => #<Process::Status: pid 1380 exit 15>
See also .kill .maxgroups .initgroups .maxgroups= also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0