Commit 5317b7de authored by Chad MILLER's avatar Chad MILLER

Bug#11122: Server won't always start when cold-booting after a crash

The grep expression that finds a running "mysqld" program fails if the
"mysqld_safe" is running with the same PID.

Now, excise "ps" output that has the word " grep" or "mysqld_safe" in 
it, to be a little more certain that the matched process is not a false 
positive hit.  This will fail when the path to mysqld contains either
of those two names, which should be acceptable.

Additionally, some text to search could be truncated if very long.  
Expand the number of lines "ps" emits.
parent 27a17b25
...@@ -504,46 +504,54 @@ then ...@@ -504,46 +504,54 @@ then
fi fi
AC_SUBST(ICHECK) AC_SUBST(ICHECK)
# Lock for PS # Look for PS usage. We use double dollar-signs in FIND_PROC because this
# value is written to a makefile, which interprets away one level of
# dollar-signs. So, interpretation stages are m4 and then shell in autoconf,
# then Make, then shell .
#
# We use grep -E Foo space-or-EOL so that we don't falsely match "Foo_safe" .
# Assumption is that if there are parameters, the system represents them using
# space as a seperator. This has the side effect that the matching expression
# does not match itself, and so grep won't self-match.
AC_PATH_PROG(PS, ps, ps) AC_PATH_PROG(PS, ps, ps)
AC_MSG_CHECKING("how to check if pid exists") AC_MSG_CHECKING("how to check if pid exists")
PS=$ac_cv_path_PS PS=$ac_cv_path_PS
# Linux style # Linux style
if $PS p $$ 2> /dev/null | grep `echo $0 | sed s/\-//` > /dev/null if $PS wwwp $$ 2> /dev/null | grep -- "$0" > /dev/null
then then
FIND_PROC="$PS p \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS wwwp \$\$PID | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
# Solaris # Solaris
elif $PS -fp $$ 2> /dev/null | grep $0 > /dev/null elif $PS -fp $$ 2> /dev/null | grep -- $0 > /dev/null
then then
FIND_PROC="$PS -p \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS -p \$\$PID | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
# BSD style # BSD style
elif $PS -uaxww 2> /dev/null | grep $0 > /dev/null elif $PS -uaxww 2> /dev/null | grep -- $0 > /dev/null
then then
FIND_PROC="$PS -uaxww | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -uaxww | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
# SysV style # SysV style
elif $PS -ef 2> /dev/null | grep $0 > /dev/null elif $PS -ef 2> /dev/null | grep -- $0 > /dev/null
then then
FIND_PROC="$PS -ef | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -ef | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
# Do anybody use this? # Do anybody use this?
elif $PS $$ 2> /dev/null | grep $0 > /dev/null elif $PS $$ 2> /dev/null | grep -- $0 > /dev/null
then then
FIND_PROC="$PS \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS \$\$PID | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
else else
case $SYSTEM_TYPE in case $SYSTEM_TYPE in
*freebsd*|*dragonfly*) *freebsd*|*dragonfly*)
FIND_PROC="$PS p \$\$PID | grep -v grep | grep \$\$MYSQLD > /dev/null" FIND_PROC="$PS p \$\$PID | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" > /dev/null"
;; ;;
*darwin*) *darwin*)
FIND_PROC="$PS -uaxww | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -uaxww | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
;; ;;
*cygwin*) *cygwin*)
FIND_PROC="$PS -e | grep -v grep | grep \$\$MYSQLD | grep \" \$\$PID \" > /dev/null" FIND_PROC="$PS -e | grep -v ' grep' | grep -v mysqld_safe | grep -- \"\$\$MYSQLD\" | grep \" \$\$PID \" > /dev/null"
;; ;;
*netware*) *netware*)
FIND_PROC= FIND_PROC=
;; ;;
*) *)
AC_MSG_ERROR([Could not find the right ps switches. Which OS is this ?. See the Installation chapter in the Reference Manual.]) AC_MSG_ERROR([Could not find the right ps and/or grep switches. Which OS is this? See the Installation chapter in the Reference Manual.])
esac esac
fi fi
AC_SUBST(FIND_PROC) AC_SUBST(FIND_PROC)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment