Class: RightScale::RightPopen::ProcessStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/right_popen/process_status.rb

Overview

Quacks like Process::Status, which we cannot instantiate ourselves because has no public new method for cases where we need to create our own.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid, exitstatus, termsig = nil) ⇒ ProcessStatus

Parameters

Parameters:

  • pid (Integer) —

    as process identifier

  • exitstatus (Integer) —

    as process exit code or nil

  • termination (Integer) —

    signal or nil



41
42
43
44
45
# File 'lib/right_popen/process_status.rb', line 41

def initialize(pid, exitstatus, termsig=nil)
  @pid = pid
  @exitstatus = exitstatus
  @termsig = termsig
end

Instance Attribute Details

#exitstatus ⇒ Object (readonly)

Returns the value of attribute exitstatus.



35
36
37
# File 'lib/right_popen/process_status.rb', line 35

def exitstatus
  @exitstatus
end

#pid ⇒ Object (readonly)

Returns the value of attribute pid.



35
36
37
# File 'lib/right_popen/process_status.rb', line 35

def pid
  @pid
end

#termsig ⇒ Object (readonly)

Returns the value of attribute termsig.



35
36
37
# File 'lib/right_popen/process_status.rb', line 35

def termsig
  @termsig
end

Instance Method Details

#exited? ⇒ TrueClass

Simulates Process::Status.exited? which seems like a weird method since this object cannot logically be queried until the process exits.

Returns

Returns:

  • (TrueClass) —

    always true



52
53
54
# File 'lib/right_popen/process_status.rb', line 52

def exited?
  return true
end

#success? ⇒ Boolean

Simulates Process::Status.success?

Returns

true if the process returned zero as its exit code or nil if terminate was signalled

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/right_popen/process_status.rb', line 60

def success?
  # note that Linux ruby returns nil when exitstatus is nil and a termsig
  # value is set instead.
  return @exitstatus ? (0 == @exitstatus) : nil
end