Ruby 2.5 adds Process#last_status

Ruby 2.5 was recently released.

Ruby 2.5 has added Process#last_status as an alias for $?

It returns the status of the last executed child process in the current thread.

>> Process.wait Process.spawn("exit 0")
=> 18447
>> $?
=> #<Process::Status: pid 18447 exit 0>
>> Process.last_status
=> #<Process::Status: pid 18447 exit 0>
>> Process.last_status == $?
=> true

It returns nil if no child process has been ever executed in the current thread

>> Process.last_status
=> nil

It doesn’t accept any arguments.

>> Process.last_status(1)
Traceback (most recent call last):
3: from /home/atul/.rvm/rubies/ruby-2.5.0/bin/irb:11:in `<main>'
2: from (irb):2
1: from (irb):2:in `last_status'
ArgumentError (wrong number of arguments (given 1, expected 0))