Last active
December 17, 2015 14:09
-
-
Save andersonvom/5622242 to your computer and use it in GitHub Desktop.
Stop Checkmate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. Got it.