Merge pull request #2 from ged/better-357-fix

A better fix for #357.
This commit is contained in:
dlage committed 2014-03-17 19:29:45 +00:00
commit 9905334f01
1 file changed
+3 -15
+3 -15
View File
@@ -177,18 +177,13 @@ class Foreman::Engine
# @param [String] signal The signal to send to each process # @param [String] signal The signal to send to each process
# #
def kill_children( signal="SIGTERM" ) def kill_children( signal="SIGTERM" )
if Foreman.windows?
@running.each do |pid, (process, index)| @running.each do |pid, (process, index)|
system "sending #{signal} to #{name_for(pid)} at pid #{pid}" system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
begin begin
Process.kill( signal, pid ) Process.kill( signal, pid )
rescue Errno::ESRCH, Errno::EPERM rescue Errno::ESRCH, Errno::EPERM => err
end system " %p when sending signal %p to pid %d: %s" %
end [ err.class, signal, pid, err.message ]
else
begin
Process.kill signal, *@running.keys unless @running.empty?
rescue Errno::ESRCH, Errno::EPERM
end end
end end
end end
@@ -198,14 +193,7 @@ class Foreman::Engine
# @param [String] signal The signal to send # @param [String] signal The signal to send
# #
def killall(signal="SIGTERM") def killall(signal="SIGTERM")
if Foreman.windows?
kill_children(signal) kill_children(signal)
else
begin
Process.kill "-#{signal}", Process.pid
rescue Errno::ESRCH, Errno::EPERM
end
end
end end
# Get the process formation # Get the process formation