From 76cd2e794b31dafc46abb8fefd2ab82fb44b94ef Mon Sep 17 00:00:00 2001 From: David Dollar Date: Sun, 15 Jan 2012 12:59:47 -0500 Subject: [PATCH] Revert "Merge pull request #125 from brainopia/master" It appears that this is causing issues with process termination. This reverts commit d2c9ce0f34759eaa8751203affd783be93bd3796, reversing changes made to 98337c92e1803977c25f4f871ea59f2ed5559cf5. --- bin/runner | 4 ++-- lib/foreman/engine.rb | 8 +------- lib/foreman/process.rb | 2 -- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/bin/runner b/bin/runner index 89257a0..69011a5 100755 --- a/bin/runner +++ b/bin/runner @@ -1,2 +1,2 @@ -#!/usr/bin/env ruby -exec "#{ARGV.join(' ')} 2>&1" +#!/bin/sh +exec $1 2>&1 diff --git a/lib/foreman/engine.rb b/lib/foreman/engine.rb index 7e8df1f..c65a5a5 100644 --- a/lib/foreman/engine.rb +++ b/lib/foreman/engine.rb @@ -72,16 +72,10 @@ private ###################################################################### def kill_all(signal="SIGTERM") running_processes.each do |pid, process| info "sending #{signal} to pid #{pid}" - kill(signal, -pid) or kill(signal, pid) + Process.kill(signal, pid) rescue Errno::ESRCH end end - def kill(signal, pid) - Process.kill signal, pid - rescue Errno::ESRCH - false - end - def terminate_gracefully info "sending SIGTERM to all processes" kill_all "SIGTERM" diff --git a/lib/foreman/process.rb b/lib/foreman/process.rb index e570719..06f79f6 100644 --- a/lib/foreman/process.rb +++ b/lib/foreman/process.rb @@ -30,13 +30,11 @@ private def fork_with_io(command) reader, writer = IO.pipe pid = fork do - Process.setpgrp trap("INT", "IGNORE") $stdout.reopen writer reader.close exec Foreman.runner, replace_command_env(command) end - Process.detach pid [ reader, pid ] end