-
Notifications
You must be signed in to change notification settings - Fork 144
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
launch not killing processes started with shell=True #545
Comments
Hmm, @v-lopez this looks like Gazebo not forwarding signals properly. Would you mind trying to force |
I tried that (and verified that it was not being overwritten to |
I have the same problem with a standalone unity executable not being killed, but I can kill all the processes correctly if I Ctrl+C before the test is complete |
My current workaround is to add a
I think the reason this is happening is because the executable is ran from a series of launch files, then the last launch file calls a bash script that uses |
I'm experiencing this issue with gzserver, gzclient, and rqt. Here's a minimal reproducible example with Gazebo: import sys
import time
import unittest
import launch
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.substitutions import FindPackageShare
from launch_testing.actions import ReadyToTest
import launch_testing.markers
import pytest
@pytest.mark.launch_test
def generate_test_description():
return launch.LaunchDescription(
[
IncludeLaunchDescription(
PythonLaunchDescriptionSource([FindPackageShare('gazebo_ros'), '/launch/gazebo.launch.py'])
),
ReadyToTest(),
])
class MyTestFixture(unittest.TestCase):
def test_something(self):
time.sleep(10.0)
print('END TEST', file=sys.stderr) |
We were facing a similar issue in ignition fortress, where launch was not able to kill the gazebo process. As @hidmic mentioned, it was related to Gazebo not forwarding signals. That was fixed using this PR, not sure if that is related : gazebosim/gz-launch#151 |
Fix here : ros-simulation/gazebo_ros_pkgs#1376 |
Another minimal example :
Where both test files are just :
|
This is not a problem IMO. You probably can fix that be trapping SIGINT/SIGTERM and killing subprocesses before exiting the shell (e.g. with I don't think we can do anything by default in launch that's reasonable, people should be careful when using |
I have updated the issue title, as I don't think the original one was correct. |
This is easy to reproduce from a pure launch file: ros2 launch ./test.launch.py &
kill -SIGINT $! # ./test.launch.py
import launch
from launch.actions import ExecuteProcess
PYTHON_SCRIPT="""\
import time
while 1:
time.sleep(0.5)
"""
def generate_launch_description():
return launch.LaunchDescription(
[
ExecuteProcess(
cmd=['python3', '-c', f'"{PYTHON_SCRIPT}"'],
shell=True,
output='both'
),
ExecuteProcess(
cmd=['python3', '-c', f'{PYTHON_SCRIPT}'],
shell=False,
output='both'
),
]) after waiting the launch process to finish (it will take some seconds and log some stuff), it's easy to check that the second process was killed and the first wasn't (e.g. using Note:
I will give it a try to the last option, but I'm not sure how multiplatform that's going to be. cc @jacobperron |
I have opened #632, which will fix the issue. |
This issue has been mentioned on ROS Discourse. There might be relevant details there: |
Bug report
Required Info:
Steps to reproduce issue
Execute it with
launch_test
or as part ofadd_launch_test
in CMake.Expected behavior
When it ends, gazebo should be killed.
Actual behavior
Gazebo is not killed.
Additional information
Happens with other nodes besides gazebo. But gazebo is particularly troublesome because I cannot have 2 tests running sequentially using gazebo, because the first test didn't kill the server, and only one server may be running in a machine.
Might be related to #495 because if instead of
launch_testing
I useros2 launch gazebo_ros gazebo.launch.py
, I can kill it properly with Ctrl+C, but not withkill -SIGINT
. Even if I useros2 launch gazebo_ros gazebo.launch.py --noninteractive
The text was updated successfully, but these errors were encountered: