From 0ae144e4683eabbca69ef092ed0ca0f5ddd4e5fe Mon Sep 17 00:00:00 2001 From: David Dollar Date: Fri, 15 Oct 2010 16:06:06 -0700 Subject: [PATCH] better handling of Interrupt rescues --- lib/foreman/engine.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/foreman/engine.rb b/lib/foreman/engine.rb index accf6cd..2966eed 100644 --- a/lib/foreman/engine.rb +++ b/lib/foreman/engine.rb @@ -84,18 +84,21 @@ private ###################################################################### def run(process, log_to_file=true) proctitle "ruby: foreman #{process.name}" - Dir.chdir directory do - FileUtils.mkdir_p "log" - command = process.command + begin + Dir.chdir directory do + FileUtils.mkdir_p "log" + command = process.command - begin PTY.spawn("#{process.command} 2>&1") do |stdin, stdout, pid| until stdin.eof? info stdin.gets, process end end - rescue PTY::ChildExited, Interrupt - info "process exiting", process rescue nil + end + rescue PTY::ChildExited, Interrupt + begin + info "process exiting", process + rescue Interrupt end end end