clearpathrobotics / robot_upstart

ROS package of helper functions related to bringing up roslaunch on system startup.
BSD 3-Clause "New" or "Revised" License
196 stars 96 forks source link

stopping doesn't wait for nodes to exit #39

Closed zacwitte closed 7 years ago

zacwitte commented 8 years ago

We're using robot_upstart to manage our ROS nodes and it's all working great except for the sudo service ros stop command. It finishes the command immediately, but the ROS nodes take an extra 10-20 seconds before they actually shut down. This causes big problems if we're trying to restart the software because nodes will be coming up and down at the same time, which makes everything confused.

Is it possible for the upstart script to track which pids and all children pids were created and wait until they're all terminated before finishing the command?

mikepurvis commented 8 years ago

Sure, please send a PR that does this. You'll want something like:

kill $(< $PIDFILE)
logger -s -p user.info "Waiting for roslaunch process to end"
while kill -0 "$(< $PIDFILE)" 2>/dev/null; do sleep 0.2; done
rm $PIDFILE