ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can I send a SIGINT to a single node?

asked 2017-04-19 12:46:06 -0600

cpagravel gravatar image

I have a process that will cause roslaunch to shutdown with a SIGINT. I've found out that roslaunch has a maximum wait time of 15 seconds before it will escalate to a SIGTERM. This is occasionally not long enough for my reporter node to gracefully close since it will perform calculations and prepare a report when a SIGINT is received.

I think I can get around this if I can send a SIGINT directly to this node (not through roslaunch) and then afterwards I could send a SIGINT to roslaunch. Is there a way to do this? I read about using rosnode kill but that will not trigger a SIGINT.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2017-04-19 13:09:09 -0600

Wolf gravatar image

You could send a using basic linux methods to the process, but I don't think this would be a clean solution.

This thread:

http://answers.ros.org/question/27655...

contains a very good example for implementing both, rosnode kill and SIGINT handler. I you implemented your node following this pattern you could trigger its shutdown via rosnode kill.

edit flag offensive delete link more
1

answered 2017-04-19 17:28:19 -0600

Geoff gravatar image

If you really want to use kill on a node's process, you can find the PID for the node in the log file produced by roslaunch (it's path is printed at the start of the launch output). But the answer that Wolf mentioned, and using rosnode kill, is a better solution.

You could also re-consider your architecture. Rather than trying to beat the roslaunch shutdown time limit, you could have your reporter node spit out the raw data that it would be working with and then process that using another program after roslaunch shuts down.

edit flag offensive delete link more

Comments

Your suggestion is quite good. I'll consider that.

cpagravel gravatar image cpagravel  ( 2017-04-20 11:18:41 -0600 )edit

Geoff, I actually decided to go with your suggestion. I am keeping Wolf's answer as the correct one since people searching for this question will likely be more interested in his answer, however your answer turned out to be the better one for me. Kudos and thank you for that.

cpagravel gravatar image cpagravel  ( 2017-04-20 12:18:00 -0600 )edit

Happy to help! :)

Geoff gravatar image Geoff  ( 2017-04-20 18:07:08 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-19 12:46:06 -0600

Seen: 1,864 times

Last updated: Apr 19 '17