Skip to content

Commit d0be807

Browse files
author
David Harsha
committed
Run processes in new pgroup
Some processes are getting orphaned when running Foreman with JRuby. Creating a new pgroup allows them all to be killed together. I believe the issue is related to how JRuby handles `Dir.chdir` by creating a shell process: `sh -c 'cd /chdir/target; ${command}'`. That causes a second process to be created that won't get cleaned up by killing the parent.
1 parent c0b178c commit d0be807

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/foreman/process.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ def run(options={})
4949
env = @options[:env].merge(options[:env] || {})
5050
output = options[:output] || $stdout
5151
runner = "#{Foreman.runner}".shellescape
52-
52+
pgroup = Foreman.windows? ? :new_pgroup : :pgroup
53+
5354
Dir.chdir(cwd) do
54-
Process.spawn env, expanded_command(env), :out => output, :err => output
55+
Process.spawn env, expanded_command(env), :out => output, :err => output, pgroup => true
5556
end
5657
end
5758

0 commit comments

Comments
 (0)