Type:
Class

Process::Status encapsulates the information on the status of a running or terminated system process. The built-in variable $? is either nil or a Process::Status object.

1
2
3
4
5
6
7
8
fork { exit 99 }   #=> 26557
Process.wait       #=> 26557
$?.class           #=> Process::Status
$?.to_i            #=> 25344
$? >> 8            #=> 99
$?.stopped?        #=> false
$?.exited?         #=> true
$?.exitstatus      #=> 99

Posix systems record information on processes using a 16-bit integer. The lower bits record the process status (stopped, exited, signaled) and the upper bits possibly contain additional information (for example the program's return code in the case of exited processes). Pre Ruby 1.8, these bits were exposed directly to the Ruby program. Ruby now encapsulates these in a Process::Status object. To maximize compatibility, however, these objects retain a bit-oriented interface. In the descriptions that follow, when we talk about the integer value of stat, we're referring to this 16 bit value.

termsig
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.termsig â fixnum or nil Instance Public methods Returns the number of

2025-01-10 15:47:30
stopsig
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.stopsig â fixnum or nil Instance Public methods Returns the number of

2025-01-10 15:47:30
exited?
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.exited? â true or false Instance Public methods Returns true

2025-01-10 15:47:30
success?
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.success? â true, false or nil Instance Public methods Returns true

2025-01-10 15:47:30
>>
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat >> num â fixnum Instance Public methods Shift the bits in stat

2025-01-10 15:47:30
inspect
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.inspect â string Instance Public methods Override the inspection method

2025-01-10 15:47:30
==
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat == other â true or false Instance Public methods Returns true

2025-01-10 15:47:30
to_i
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.to_i â fixnumstat.to_int â fixnum Instance Public methods Returns

2025-01-10 15:47:30
to_s
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.to_s â string Instance Public methods Show pid and exit status as a

2025-01-10 15:47:30
coredump?
  • References/Ruby on Rails/Ruby/Classes/Process/Process::Status

stat.coredump? â true or false Instance Public methods Returns true

2025-01-10 15:47:30