class Phantom::Base

Attributes

name[R]
pid[R]

Public Class Methods

new(pid, name=nil) click to toggle source
# File lib/phantom/base.rb, line 5
def initialize(pid, name=nil)
  @pid = pid.nil? ? nil : pid.to_i
  @name = name
end

Public Instance Methods

abort!() click to toggle source
# File lib/phantom/base.rb, line 34
def abort!
  kill(:ABRT) if alive?
end
alive?() click to toggle source
# File lib/phantom/base.rb, line 67
def alive?
  !dead?
end
continue() click to toggle source
# File lib/phantom/base.rb, line 50
def continue
  if alive?
    kill(:CONT)
    @status = Phantom::Status::ALIVE
  end
end
Also aliased as: resume
dead?() click to toggle source
# File lib/phantom/base.rb, line 71
def dead?
  status == Phantom::Status::DEAD
end
gid() click to toggle source
# File lib/phantom/base.rb, line 18
def gid
  @gid ||= Process.getpgid(@pid)
end
group_priority() click to toggle source
# File lib/phantom/base.rb, line 26
def group_priority
  @group_priority ||= Process.getpriority(Process::PRIO_PGRP, @pid)
end
kill(signal) click to toggle source
# File lib/phantom/base.rb, line 10
def kill(signal)
  Process.kill(signal, @pid) if @pid
end
pause()
Alias for: stop
process_priority() click to toggle source
# File lib/phantom/base.rb, line 30
def process_priority
  @process_priority ||= Process.getpriority(Process::PRIO_PROCESS, @pid)
end
resume()
Alias for: continue
sid() click to toggle source
# File lib/phantom/base.rb, line 14
def sid
  @sid ||= Process.getsid(@pid)
end
status() click to toggle source
# File lib/phantom/base.rb, line 58
def status
  begin
    Process.kill(0, @pid)
    return @status ||= Phantom::Status::ALIVE
  rescue Errno::ESRCH
    return @status = Phantom::Status::DEAD
  end
end
stop() click to toggle source
# File lib/phantom/base.rb, line 42
def stop
  if alive?
    kill(:STOP)
    @status = Phantom::Status::PAUSED
  end
end
Also aliased as: pause
terminate() click to toggle source
# File lib/phantom/base.rb, line 38
def terminate
  kill(:TERM) if alive?
end
user_priority() click to toggle source
# File lib/phantom/base.rb, line 22
def user_priority
  @user_priority ||= Process.getpriority(Process::PRIO_USER, @pid)
end