Skip to content

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.
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.

4 participants