lib/datacenter/process.rb in datacenter-0.1.1 vs lib/datacenter/process.rb in datacenter-0.1.2

- old
+ new

@@ -28,21 +28,13 @@ info[attribute] end end def alive? - send_signal 0 - true - rescue Errno::ESRCH - false + shell.run("ls /proc | grep #{pid}") == pid.to_s end - def send_signal(signal) - out = shell.run("kill -s #{signal} #{pid}") - raise Errno::ESRCH, pid.to_s if out.match 'No such process' - end - def stop send_signal :QUIT if alive? end def kill @@ -52,9 +44,13 @@ private attr_reader :shell + def send_signal(signal) + shell.run "kill -s #{signal} #{pid}" + end + def info @cache.fetch(:info) do ps = shell.run('ps aux').scan(/.*#{pid}.*/)[0].split Hash.new.tap do |info| status = Hash[proc_file(:status).split("\n").map{ |s| s.split(':').map(&:strip) }]