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

Use exec instead of popen to run ign-launch binary #151

Merged
merged 1 commit into from
Mar 18, 2022
Merged

Conversation

azeey
Copy link
Contributor

@azeey azeey commented Mar 17, 2022

🦟 Bug fix

Fixes #149

Summary

Currently, the ruby processes creates a new process to run the ign-launch binary. For some reason, signals sent to the ruby processes don't propagate to the child process. In addition to the issue described in #149, sending a SIGINT signal (or even SIGKILL) directly via kill to the parent process doesn't terminate the launched process.

For example, launch the following:

sleep.ign

<?xml version='1.0'?>
<ignition version='1.0'>
  <executable name='sleep_ign'>
    <command>sleep 100</command>
  </executable>
</ignition>

Launch with: ign launch sleep.ign

The process list shows there are two processes associated with the launch

❯ ps x --forest  | grep ign
1423316 pts/24   Sl+    0:00  |   |   \_ ign launch sleep.ign
1423346 pts/24   Sl+    0:00  |   |       \_ /home/addisu/ws/fortress/install/lib/ignition/launch5/ign-launch sleep.ign

Killing the top/parent process does not terminate the child

❯ kill -SIGINT 1423316
❯ ps x --forest  | grep ign
1423346 pts/24   Sl     0:00  \_ /home/addisu/ws/fortress/install/lib/ignition/launch5/ign-launch sleep.ign

https://www.vidarholen.net/contents/blog/?p=34 explains the problem (which I learned about from ros2/launch#484).

The solution I propose is to replace the ruby process with the ign-launch process using exec. Here's the process list with the new approach.

❯ ps x --forest  | grep ign
1431877 pts/24   Sl+    0:00  |   |   \_ /home/addisu/ws/fortress/install/lib/ignition/launch5/ign-launch sleep.ign

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@azeey azeey requested a review from nkoenig as a code owner March 17, 2022 19:46
@azeey azeey self-assigned this Mar 17, 2022
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Mar 17, 2022
@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #151 (e25dc07) into ign-launch5 (b63eb2e) will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff              @@
##           ign-launch5     #151   +/-   ##
============================================
  Coverage        32.92%   32.92%           
============================================
  Files                4        4           
  Lines              817      817           
============================================
  Hits               269      269           
  Misses             548      548           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b63eb2e...e25dc07. Read the comment docs.

Copy link
Contributor

@adityapande-1995 adityapande-1995 left a comment

Choose a reason for hiding this comment

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

I'm not familiar with this package, but is there a possible case whereign launch ... launches one more process in addition to ign-launch binary ?

@azeey
Copy link
Contributor Author

azeey commented Mar 18, 2022

I'm not familiar with this package, but is there a possible case whereign launch ... launches one more process in addition to ign-launch binary ?

I don't think so. All the processes that are in the launch file are started by the ign-launch binary.

@azeey azeey merged commit 909e856 into ign-launch5 Mar 18, 2022
@azeey azeey deleted the use_exec branch March 18, 2022 15:26
azeey added a commit to gazebosim/gz-transport that referenced this pull request Mar 23, 2022
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-03-25-fortress-edifice-citadel/1343/1

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

Successfully merging this pull request may close these issues.

Executables don't terminate when ign launch is terminated
4 participants