Ask Your Question
0

Functional difference? pkill vs. rosnode kill

asked 2017-10-28 19:57:14 -0500

AndyZe gravatar image

I'm just curious if there's a preferred way to kill a node or if it's all the same underneath.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-10-29 02:25:00 -0500

gvdhoorn gravatar image

pkill is an OS utility that uses OS infrastructure to forcibly terminate the process that is your node. The node gets notified that this is going to happen via various signals), which it can use to perform pre-shutdown operations. See also pkill(1).

rosnode kill will use the XML-RPC server in each node to send it (something akin to) a service request (shutdown(..), see ROS/Slave_API) that will set some client-lib internal variable(s) that eventually cause it exit any while(ros::ok()) { .. } or ros::spin() loops. The node may then perform any cleanup actions it has defined.

I'm just curious if there's a preferred way to kill a node or if it's all the same underneath.

No, it's not the same, and I would say it is probably nicer to use rosnode kill, as the signals that pkill uses may not make it to the process hosting your node, but even if they do, they may not give your node (and the middleware infrastructure running in the same process) enough time to gracefully shut down.

edit flag offensive delete link more

Comments

Note also that there is no authentication or other form of security on shutdown(..), so it provides a nice way to take down an entire ROS application as a 'bad actor'.

gvdhoorn gravatar imagegvdhoorn ( 2017-10-29 02:26:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-10-28 19:57:14 -0500

Seen: 142 times

Last updated: Oct 29 '17