From 44726e377efe80efee40260fea7280f2f91097f4 Mon Sep 17 00:00:00 2001 From: Christos Trochalakis Date: Thu, 27 Dec 2012 15:24:24 +0200 Subject: [PATCH] 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. --- lib/foreman/engine.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/foreman/engine.rb b/lib/foreman/engine.rb index 4d0fefa..6519f6e 100644 --- a/lib/foreman/engine.rb +++ b/lib/foreman/engine.rb @@ -37,6 +37,9 @@ class Foreman::Engine # Start the processes registered to this +Engine+ # def start + # Make sure foreman is the process group leader. + Process.setpgrp unless Foreman.windows? + trap("TERM") { puts "SIGTERM received"; terminate_gracefully } trap("INT") { puts "SIGINT received"; terminate_gracefully } trap("HUP") { puts "SIGHUP received"; terminate_gracefully } if ::Signal.list.keys.include? 'HUP' @@ -109,7 +112,7 @@ class Foreman::Engine end else begin - Process.kill "-#{signal}", Process.pid + Process.kill "-#{signal}", Process.getpgrp rescue Errno::ESRCH, Errno::EPERM end end