Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Process::Status#exitstatus

stat.exitstatus → integer or nil

Returns the least significant eight bits of the return code of stat. Only available if exited? is true.

Example
fork { }           #=> 26572
Process.wait       #=> 26572
$?.exited?         #=> true
$?.exitstatus      #=> 0

fork { exit 99 }   #=> 26573
Process.wait       #=> 26573
$?.exited?         #=> true
$?.exitstatus      #=> 99
See also #exited? #inspect #coredump? #pid also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0