module Process
Monkey patch Process
with some useful methods
Public Class Methods
killall(term)
click to toggle source
Kill the process found with the given search term @param term [String] search term to use to find the pid
# File lib/nub/process.rb, line 38 def self.killall(term) pid = pidof(term) Process.kill("KILL", pid) if pid end
pidof(term)
click to toggle source
Get the pid of the process found with the given search term @param term [String] search term to use to find the pid
# File lib/nub/process.rb, line 27 def self.pidof(term) pid = nil str = `ps -ef | grep "[#{term[0]}]#{term[1..-1]}"` pid = str.split()[1].to_i if !str.empty? return pid end