Skip to content

Instantly share code, notes, and snippets.

@andersonvom
Last active December 17, 2015 14:09
Show Gist options
  • Save andersonvom/5622242 to your computer and use it in GitHub Desktop.
Save andersonvom/5622242 to your computer and use it in GitHub Desktop.
Stop Checkmate
#
# Function that stops the daemon/service
#
do_stop()
{
if [ ! -e $PIDFILE ]; then
return 2
fi
pid=`cat $PIDFILE`
children=$(ps axo pid,ppid | awk "{ if ( \$2 == $pid ) { print \$1 }}")
if [ "$children" = "" ]; then # add this check:
kill $pid # if there are no child processes, then just kill the one process.
else
for child in $children
do
# echo "Killing child process $child because ppid = $pid"
kill $child
done
fi
rm $PIDFILE
return 0
}
@ziadsawalha
Copy link

Thanks. Got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment