class AfterNotifier::PidGuard

Constants

SLEEP_TIME

Public Class Methods

new(pid) click to toggle source
# File lib/after_notifier/pid_guard.rb, line 7
def initialize(pid)
  @pid = pid.to_i
end

Public Instance Methods

finished?() click to toggle source
# File lib/after_notifier/pid_guard.rb, line 11
def finished?
  # At first PID should be exisited.
  raise UnknownPid, 'Should set exist PID' unless exists?

  loop do
    return true unless exists?
    sleep SLEEP_TIME
  end
end

Private Instance Methods

exists?() click to toggle source
# File lib/after_notifier/pid_guard.rb, line 23
def exists?
  !!::Process.kill(0, @pid) rescue false # signal 0 process alive monitoring
end