Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run processes in new pgroup #723

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davishmcclurg
Copy link

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.

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.
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sends the signal to all processes in the group. I still saw leftover processes when the signal was sent only to the parent

@baelter
Copy link

baelter commented Dec 22, 2021

This PR is needed for rerun to work with foreman on Ubuntu.

@davishmcclurg
Copy link
Author

This PR is needed for rerun to work with foreman on Ubuntu.

I think there's a new version here: #780

@baelter
Copy link

baelter commented Dec 27, 2021

@davishmcclurg Yes, that was actually the branch I tested with.

@dentarg
Copy link

dentarg commented Oct 28, 2022

I forked foreman and merged #780 (this PR but rebased) and released the fork as overman: https://github.com/spinels/overman, https://rubygems.org/gems/overman, #780 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants