9abc751
#!/bin/sh
9abc751
9abc751
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
9abc751
9abc751
# This script waits for mysqld to be properly stopped
9abc751
# (which can be many seconds in some large load).
9abc751
# Running this as ExecStopPost is useful so that starting which is done
9abc751
# as part of restart doesn't see the former process still running.
9abc751
9abc751
# Wait for the server to properly end the main server
9abc751
ret=0
9abc751
TIMEOUT=60
9abc751
SECONDS=0
9abc751
9abc751
if ! [ -f "$pidfile" ]; then
9abc751
	exit 0
9abc751
fi
9abc751
9abc751
MYSQLPID=`cat "$pidfile" 2>/dev/null`
9abc751
if [ -z "$MYSQLPID" ] ; then
9abc751
	exit 2
9abc751
fi
9abc751
9abc751
while /bin/true; do
9abc751
	# Check process still exists
9abc751
	if ! [ -d "/proc/${MYSQLPID}" ] ; then
9abc751
	    break
9abc751
	fi
9abc751
	if [ $SECONDS -gt $TIMEOUT ] ; then
9abc751
	    ret=3
9abc751
	    break
9abc751
	fi
9abc751
	sleep 1
9abc751
done
9abc751
9abc751
exit $ret