Skip to content

Commit

Permalink
copy of ddollar#780
Browse files Browse the repository at this point in the history
  • Loading branch information
avner-vcita committed Sep 19, 2023
1 parent 82387cc commit e5ad5f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/foreman/engine.rb
Expand Up @@ -191,14 +191,14 @@ def kill_children(signal="SIGTERM")
@running.each do |pid, (process, index)|
system "sending #{signal} to #{name_for(pid)} at pid #{pid}"
begin
Process.kill(signal, pid)
Process.kill("-#{signal}", pid)
rescue Errno::ESRCH, Errno::EPERM
end
end
else
begin
pids = @running.keys.compact
Process.kill signal, *pids unless pids.empty?
Process.kill("-#{signal}", *pids) unless pids.empty?
rescue Errno::ESRCH, Errno::EPERM
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/foreman/process.rb
Expand Up @@ -49,9 +49,11 @@ def run(options={})
env = @options[:env].merge(options[:env] || {})
output = options[:output] || $stdout
runner = "#{Foreman.runner}".shellescape


pgroup = Foreman.windows? ? :new_pgroup : :pgroup

Dir.chdir(cwd) do
Process.spawn env, expanded_command(env), :out => output, :err => output
Process.spawn env, expanded_command(env), :out => output, :err => output, pgroup => true
end
end

Expand Down

0 comments on commit e5ad5f6

Please sign in to comment.