--- mysqld_safe.sh	2008-08-28 11:40:52.000000000 -0400
+++ mysqld_safe_mod.sh	2008-10-05 10:10:12.000000000 -0400
@@ -513,6 +513,30 @@
   fi
 fi
 
+# if there exists a socket file, check if server is alive.
+# If it gets alive signal by ping command from mysqladmin
+# then terminate, otherwise proceed.
+if test -S $safe_mysql_unix_port
+then
+  if test -x ./bin/mysqladmin
+  then
+    my_admin="./bin/mysqladmin"
+  elif test -x @bindir@/mysqladmin
+  then
+    my_admin="@bindir@/mysqladmin"
+  else
+    my_admin="mysqladmin"
+  fi
+
+  cmd="$my_admin --socket=$safe_mysql_unix_port $USER_OPTION ping"
+  if eval $cmd | grep -v grep | grep "mysqld is alive" > /dev/null
+  then
+    echo "A mysqld process is alive on socket "$safe_mysql_unix_port
+    echo "A mysqld process is alive on socket "$safe_mysql_unix_port `date` >> $err_log
+    exit 1
+  fi
+fi
+
 #
 # Uncomment the following lines if you want all tables to be automatically
 # checked and repaired during startup. You should add sensible key_buffer
