class Process::Status
A Process::Status contains information about a system process.
Thread-local variable $? is initially nil. Some methods assign to it a Process::Status object that represents a system process (either running or terminated):
`ruby -e "exit 99"` stat = $? # => #<Process::Status: pid 1262862 exit 99> stat.class # => Process::Status stat.to_i # => 25344 stat.stopped? # => false stat.exited? # => true stat.exitstatus # => 99
Public Instance Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1883
def &: (Integer num) -> Integer
This method is deprecated as to_i value is system-specific; use predicate methods like exited? or stopped?, or getters like exitstatus or stopsig.
Returns the logical AND of the value of to_i with mask:
`cat /nop` stat = $? # => #<Process::Status: pid 1155508 exit 1> sprintf('%x', stat.to_i) # => "100" stat & 0x00 # => 0
ArgumentError is raised if mask is negative.
(untyped other) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1896
def ==: (untyped other) -> bool
Returns whether the value of to_i == other:
`cat /nop` stat = $? # => #<Process::Status: pid 1170366 exit 1> sprintf('%x', stat.to_i) # => "100" stat == 0x100 # => true
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1916
def >>: (Integer num) -> Integer
This method is deprecated as to_i value is system-specific; use predicate methods like exited? or stopped?, or getters like exitstatus or stopsig.
Returns the value of to_i, shifted places to the right:
`cat /nop` stat = $? # => #<Process::Status: pid 1155508 exit 1> stat.to_i # => 256 stat >> 1 # => 128 stat >> 2 # => 64
ArgumentError is raised if places is negative.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1927
def coredump?: () -> bool
Returns true if the process generated a coredump when it terminated, false if not.
Not available on all platforms.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1936
def exited?: () -> bool
Returns true if the process exited normally (for example using an exit() call or finishing the program), false if not.
() → Integer?
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1948
def exitstatus: () -> Integer?
Returns the least significant eight bits of the return code of the process if it has exited; nil otherwise:
`exit 99` $?.exitstatus # => 99
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1959
def inspect: () -> String
Returns a string representation of self:
system("false") $?.inspect # => "#<Process::Status: pid 1303494 exit 1>"
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1970
def pid: () -> Integer
Returns the process ID of the process:
system("false") $?.pid # => 1247002
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1979
def signaled?: () -> bool
Returns true if the process terminated because of an uncaught signal, false otherwise.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1988
def stopped?: () -> bool
Returns true if this process is stopped, and if the corresponding #wait call had the Process::WUNTRACED flag set, false otherwise.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 1997
def stopsig: () -> Integer?
Returns the number of the signal that caused the process to stop, or nil if the process is not stopped.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 2009
def success?: () -> bool
Returns:
-
trueif the process has completed successfully and exited. -
falseif the process has completed unsuccessfully and exited. -
nilif the process has not exited.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 2018
def termsig: () -> Integer?
Returns the number of the signal that caused the process to terminate or nil if the process was not terminated by an uncaught signal.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/process.rbs, line 2029
def to_i: () -> Integer
Returns the system-dependent integer status of self:
`cat /nop` $?.to_i # => 256