Kill rosrun gracefully
Hi All,
I am running a rosrun command to generate and publish messages continuously from a node X. But I am not able to gracefully kill the session. I am currently closing the terminal in order to stop the task.
Kindly let me know if the below 2 approaches are correct and how to implement it.
- Open a new terminal and kill the node X
- Ctrl+C to stop the the publishing of messages and return to the terminal (This is what I am actually looking for)
Code Snippet;
while(ros :: ok)
{
ros_time = ros:Time::now();
publish the message;
update the message;
ros::SpinOnce();
}
I would create a package and then run rosrun
Thank you.
It's likely the node you cannot shutdown is not correctly programmed. Common cause: not checking
ros::ok()
in your while-loop. Please show us some code of the node or check it yourself.Note btw: even if things were working correctly, you'd not be "killing rosrun", but would be shutting down the node.
@gvdhoorn Thank you for the response... code snippet does have ros::ok() condition in while loop... Is there a way I can use Ctrl+C to terminate the rosrun .?
Then please show your code, otherwise we can only guess why things don't work the way they should.
@gvdhoorn I was able to stop the node by killing it in another terminal.. however I need to know how can I use Ctrl+C to come out of terminal in this case.. I update the code soon.