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

ShutdownProcess event does not work from TimerAction #484

Closed
jacobperron opened this issue Jan 26, 2021 · 4 comments
Closed

ShutdownProcess event does not work from TimerAction #484

jacobperron opened this issue Jan 26, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@jacobperron
Copy link
Member

jacobperron commented Jan 26, 2021

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • from source
  • Version or commit hash:
    • 0.15.0

Steps to reproduce issue

launch file (repro.launch.py):

import launch
from launch.actions import ExecuteProcess
from launch.actions import EmitEvent
from launch.actions import TimerAction
from launch.events.process import ShutdownProcess
from launch.events import matches_action


def generate_launch_description():
    execute_proc = ExecuteProcess(
        cmd=['./test.sh'],
        name='my_test',
        output='screen',
    )
    kill_proc_event = EmitEvent(
        event=ShutdownProcess(
            process_matcher=matches_action(execute_proc)
        )
    )
    return launch.LaunchDescription([
        execute_proc,
        TimerAction(period=0.5, actions=[kill_proc_event]),
        # replacing the timer above with the following line works as expected (but without the time delay)
        # kill_proc_event
    ])

test process test.sh:

#!/usr/bin/env bash

echo "Test!"
sleep 1
echo "One"
sleep 1
echo "Two"
sleep 1
echo "Three"

launch command:

ros2 launch repro.launch.py

Expected behavior

After the timer expires, the ExecuteProcess action is shutdown.

Actual behavior

We see a SIGINT being sent to the process, but it is not shutdown.

Additional information

If we remove TimerAction, and emit the shutdown signal directly (see commented line in example), then the launch script behaves as expected: the test process is immediately shutdown.

@jacobperron jacobperron added the bug Something isn't working label Jan 26, 2021
@jacobperron
Copy link
Member Author

If I increase the delays in test.sh, eventually launch gives up on the SIGINT and sends a SIGTERM. This successfully kills the process:

[ERROR] [my_test-1]: process[my_test-1] failed to terminate '5' seconds after receiving 'SIGINT', escalating to 'SIGTERM'

@jacobperron
Copy link
Member Author

@hidmic I know you where dealing with signal handlers and launch recently, any ideas? Note, this doesn't look like a regression, just something that never worked.

@hidmic
Copy link
Contributor

hidmic commented Jan 27, 2021

I may be wrong, but this doesn't seem like a problem in launch. launch sends signals to your test process, but your test process does not forward signals to its child processes. Ctrl+C on a terminal with job control is not the same as SIGINT'ing the process. This blog talks about it briefly.

@jacobperron
Copy link
Member Author

You're right, launch is working as expected. I was not understanding how the terminal was interacting differently than sending a SIGINT. TIL. Thanks!

Handling the interrupt with trap or swapping in a Python script works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants