Module: Process
- Defined in:
- lib/nub/process.rb
Overview
Monkey patch Process with some useful methods
Class Method Summary collapse
-
.killall(term) ⇒ Object
Kill the process found with the given search term.
-
.pidof(term) ⇒ Object
Get the pid of the process found with the given search term.
Class Method Details
.killall(term) ⇒ Object
Kill the process found with the given search term
38 39 40 41 |
# File 'lib/nub/process.rb', line 38 def self.killall(term) pid = pidof(term) Process.kill("KILL", pid) if pid end |
.pidof(term) ⇒ Object
Get the pid of the process found with the given search term
27 28 29 30 31 32 33 34 |
# 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 |