Exception: PosixPsutil::NoSuchProcess

Inherits:
PsutilError
  • Object
show all
Defined in:
lib/posixpsutil/psutil_error.rb

Overview

Raise it if the process behind doesn’t exist when you try to call a method of a Process instance.

Instance Method Summary collapse

Methods inherited from PsutilError

#to_s

Constructor Details

#initialize(opt = {}) ⇒ NoSuchProcess

should be used at least like NoSuchProcess.new(pid: xxx)

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/posixpsutil/psutil_error.rb', line 13

def initialize(opt={})
  raise ArgumentError if opt[:pid].nil?
  @pid = opt[:pid] # pid must given
  @name = opt[:name] || nil
  if opt[:msg].nil?
    if @name
      details = "(pid=#{@pid}, name=#{@name.to_s})"
    else
      details = "(pid=#{@pid})"
    end
    opt[:msg] = "process no longer exists " + details
  end
  @message = opt[:msg]
end