Implement Foreman::Process#kill,detach,alive?,dead?

This commit is contained in:
brainopia
2012-01-22 22:07:01 +04:00
parent 047f106d48
commit 241b91a0d5
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -25,6 +25,24 @@ class Foreman::Process
"%s.%s" % [ entry.name, num ]
end
def kill(signal)
pid && Process.kill(signal, pid)
rescue Errno::ESRCH
false
end
def detach
pid && Process.detach(pid)
end
def alive?
kill(0)
end
def dead?
!alive?
end
private
def fork_with_io(command)
@@ -65,5 +83,4 @@ private
ensure
ENV.replace original
end
end