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