class Rush::Process

An array of these objects is returned by Rush::Box#processes.

Attributes

box[R]
cmdline[R]
command[R]
cpu[R]
mem[R]
parent_pid[R]
pid[R]
uid[R]
user[R]

Public Class Methods

all() click to toggle source
# File lib/rush/process.rb, line 56
def self.all
  Rush::Box.new('localhost').processes
end
new(params, box) click to toggle source

params is a hash returned by the system-specific method of looking up the process list.

# File lib/rush/process.rb, line 7
def initialize(params, box)
  @box = box

  @pid = params[:pid].to_i
  @uid = params[:uid].to_i
  @user = params[:user]
  @command = params[:command]
  @cmdline = params[:cmdline]
  @mem = params[:mem]
  @cpu = params[:cpu]
  @parent_pid = params[:parent_pid]
end

Public Instance Methods

alive?() click to toggle source

Returns true if the process is currently running.

# File lib/rush/process.rb, line 43
def alive?
  box.connection.process_alive(pid)
end
children() click to toggle source

Returns an array of child processes owned by this process.

# File lib/rush/process.rb, line 38
def children
  box.processes.select { |p| p.parent_pid == pid }
end
kill(options={}) click to toggle source

Terminate the process.

# File lib/rush/process.rb, line 48
def kill(options={})
  box.connection.kill_process(pid, options)
end
parent() click to toggle source

Returns the Rush::Process parent of this process.

# File lib/rush/process.rb, line 33
def parent
  box.processes.detect { |p| p.pid == parent_pid }
end