1

Rosanswers logo

I have built a ROS node with signal handling because some files needed to be closed whenever the program was interrupted. Signal handling works fine when I run the node, but if I use roslaunch the node seems not to receive the appropriate signal.

How does the roslaunch server deal with Unix signals? My opinion is that it should be able to "forward" them to all processes running under the server, but that might just be a feature request.


Originally posted by georgebrindeiro on ROS Answers with karma: 1264 on 2012-08-23

Post score: 2

2 Answers2

1

Rosanswers logo

In order to ensure all nodes are actually killed when a roslaunch instance is stopped, rather than passing signals through, roslaunch first sends SIGINT, then SIGTERM, then SIGKILL, moving from one to the next if the process doesn't exit in time.

My gut tells me that trying to pass signals through could lead to undesirable behavior, but I don't really know. If you're interested in looking into this more, I'd encourage you to bring it up with the roslaunch SIG.


Originally posted by Dan Lazewatsky with karma: 9115 on 2012-08-23

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by georgebrindeiro on 2012-08-23:
Does that happen for every signal? It seems like it happens only when I send SIGINT by pressing CTRL+C. If I send SIGTSTP by pressing CTRL+Z it seems like it simply ignores it.

0

Dan's answer is correct, roslaunch catches signals sent to the parent process and sends signals to individual processes on its own schedule. I see no way of overriding this behavior. The reason I'm adding an answer is to clarify how roslaunch itself handles the original signal, especially in terms of using the roslaunch library from python.

The roslaunch library will override the SIGINT/SIGTERM/SIGHUP signal handlers, which it uses to initiate the bring-down process described above. Unfortunately if you are not calling spin() (which returns after it brings everything down) you can get stuck. Calling spin_once() on the parent option does not return a boolean to indicate whether it was shut-down or not. Thus the only solution if you need to run other logic in the main thread is to override roslaunch's signal handlers (after calling start()) and call shutdown() on the launch parent yourself.

Luis
  • 123
  • 4