question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sigint cannot kill python talker run by bash in background mode

See original GitHub issue

Bug report

I write a bash script to run a python talker program in background, then send sigint to the talker process. The weird thing is that the python talker cannot be killed by sigint. But the cpp talker can be killed.

The same issue was also proposed in https://github.com/ros2/ros2/issues/883. As I suppose this could be a rclpy bug, so I propose it here. Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • binaries
  • Version or commit hash:
    • foxy
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclpy

Steps to reproduce issue

test.bash file:
# For python test:
python3 /opt/ros/foxy/lib/python3.6/site-packages/demo_nodes_py/topics/talker.py &

# For cpp test:
#../opt/ros/foxy/lib/demo_nodes_cpp/talker &

In terminal:

  1. bash test.bash
  2. find the talker pid, and kill -2 talker_pid

Expected behavior

cpp test: talker is killed. python test: talker is killed.

Actual behavior

cpp test: talker is killed. python test: talker continues running.

Additional information


Feature request

Feature description

Implementation considerations

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
wjwwoodcommented, Jun 2, 2020

That sounds better to me, since that’s exactly what rclcpp does.

0reactions
ivanpaunocommented, Oct 21, 2020

What? I think we should shutdown on SIGINT. That’s what rclcpp does, that’s what ROS 1 did, and I think that’s what people expect.

I think that imitating the rclcpp behavior in rclpy is ok.

What I mean is that making that change can generate random errors in places were that didn’t happen, and I would rather fix the async shutdown behavior before making a change here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to send a SIGINT to Python from a bash script?
Since loop.py is sent to background, there's no guarantee that kill runs after python loop.py. #! /bin/bash python loop.py & PID=$! # #...
Read more >
Prevent SIGINT from interrupting function call and child ...
To tell the shell to run background jobs in a separate process ... be run as a service with the appropriate kill mode...
Read more >
How To Use Bash's Job Control to Manage Foreground and ...
Once a job is in the foreground, you can kill it with CTRL + C , let it complete, or suspend and move...
Read more >
Bash Job Control - Cindy Sridharan - Medium
It's also possible to run a process in the background. Background processes don't restrict access to the shell but execute in the background...
Read more >
graceful job termination - Jenkins Jira
Using the freestyle projects to execute bash shell scripts work fine. ... is killed and Jenkins is done, go to the terminal and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found