0
$\begingroup$

Rosanswers logo

I have created a rosnode in C++. It will not be killed by rosnode kill .

Can anyone tell me why this might this might be happening?

Thanks, Paul.


Originally posted by Paul0nc on ROS Answers with karma: 271 on 2011-11-01

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

On the rosnode page, it states that rosnode kill is not guaranteed to succeed. If your node is set to "respawn", rosnode kill won't kill it properly. The other (more likely) cause of this problem is that your node is "hanging". What this means is that you're trapped in some infinite loop that does not check for the continued existence of ROS.

For example, instead of

while (1) {}

use

while (ros::ok()) {}

I've also run into problems with nodes hanging due to socket connections that fail to close properly.

In the case that you must shut down a node immediately, you can use the following command to kill it less nicely (provided that you're on a *Nix operating system):

kill $(ps aux | grep your_node | grep -v grep | awk '{print $2}')

Originally posted by DimitriProsser with karma: 11163 on 2011-11-02

This answer was ACCEPTED on the original site

Post score: 10


Original comments

Comment by Paul0nc on 2011-11-05:
Thanks Dimitri!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.