Custom SIGINT handler not triggered by roslaunch
When I run roslaunch
, it starts roscore (obviously) as well as one node. When I try to kill it by pressing CTRL+C, I get the following output:
[robot1-1] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
where robot1
is the node's name.
Here is the launch config:
<launch>
<node name="robot1" pkg="networking" type="my_node" launch-prefix="sudo -E" output="screen"/>
</launch>
I tried to implement a custom handler and followed the exact same code as in this Tutorial. I even registered the handler for SIGTERM
, SIGKILL
and SIGINT
but I don't get any output from the handler function.
Important: If I run the node manually using rosnode
, the function is called properly.
EDIT: As far as I found out, the problem is related to the launch prefix. Roslaunch runs my_node
with the prefix sudo -E
which is necessary. However, I kill it from within a non-superuser session. This would explain why it works when running the node within a superuser session. Is there a way to get aroud that?
Does the node in your launchfile have the
output=screen
attribute set?Yep, it is set and other output is printed
I think you'll have to show us what you are doing then. Without the code / a way to reproduce it, it's difficult to help you.
I updated my answer as I found out, that the launch prefix might cause a problem. I did not copy the code here as it is really just a copy of the tutorial I linked.