Sha256: f3e0bfc7e8ff16123d7614d4599ca71c8b6e3e775ec85abb25d8e793b8e07f1a

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

# An array of these objects is returned by Rush::Box#processes.
class Rush::Process
	attr_reader :box, :pid, :uid, :parent_pid, :command, :cmdline, :mem, :cpu, :user

	# params is a hash returned by the system-specific method of looking up the
	# process list.
	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

	def to_s      # :nodoc:
		inspect
	end

	def inspect   # :nodoc:
		"#{box} process #{@pid}: #{@cmdline}"
	end

	# Returns the Rush::Process parent of this process.
	def parent
		box.processes.select { |p| p.pid == parent_pid }.first
	end

	# Returns an array of child processes owned by this process.
	def children
		box.processes.select { |p| p.parent_pid == pid }
	end

	# Returns true if the process is currently running.
	def alive?
		box.connection.process_alive(pid)
	end

	# Terminate the process.
	def kill
		box.connection.kill_process(pid)
	end

	def ==(other)       # :nodoc:
		pid == other.pid and box == other.box
	end

	def self.all
		Rush::Box.new('localhost').processes
	end
end  

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
dysinger-rush-0.4.1221060147 lib/rush/process.rb
dysinger-rush-0.4.1221072146 lib/rush/process.rb
dysinger-rush-0.4 lib/rush/process.rb
rush-0.4.2 lib/rush/process.rb
rush-0.4.1 lib/rush/process.rb
rush-0.5.1 lib/rush/process.rb
rush-0.5 lib/rush/process.rb
rush-0.4 lib/rush/process.rb