Ensure foreman is the process group leader

Foreman should be the process leader before killing processes using
his process group id.

Before that foreman was broken when it was not spawned from a shell.
This commit is contained in:
Christos Trochalakis
2012-12-27 15:47:02 +02:00
parent 553ac7f81f
commit 44726e377e
+4 -1
View File
@@ -37,6 +37,9 @@ class Foreman::Engine
# Start the processes registered to this +Engine+ # Start the processes registered to this +Engine+
# #
def start def start
# Make sure foreman is the process group leader.
Process.setpgrp unless Foreman.windows?
trap("TERM") { puts "SIGTERM received"; terminate_gracefully } trap("TERM") { puts "SIGTERM received"; terminate_gracefully }
trap("INT") { puts "SIGINT received"; terminate_gracefully } trap("INT") { puts "SIGINT received"; terminate_gracefully }
trap("HUP") { puts "SIGHUP received"; terminate_gracefully } if ::Signal.list.keys.include? 'HUP' trap("HUP") { puts "SIGHUP received"; terminate_gracefully } if ::Signal.list.keys.include? 'HUP'
@@ -109,7 +112,7 @@ class Foreman::Engine
end end
else else
begin begin
Process.kill "-#{signal}", Process.pid Process.kill "-#{signal}", Process.getpgrp
rescue Errno::ESRCH, Errno::EPERM rescue Errno::ESRCH, Errno::EPERM
end end
end end