diff --git a/scripts/safe_mysqld.sh b/scripts/safe_mysqld.sh
index b2965bced9081d6cd7489de4a6ce9937c52c5045..a5ea4635ab97f21b0e8227daeef0e3d9e709c88f 100755
--- a/scripts/safe_mysqld.sh
+++ b/scripts/safe_mysqld.sh
@@ -88,13 +88,12 @@ fi
 
 
 NOHUP_NICENESS=`nohup nice`
-if [ "x$NOHUP_NICENESS" = "x0" ] || ! nice --1 nice >/dev/null 2>&1 ; then
+if test $? -ne 0 || test x"$NOHUP_NICENESS" = x0 || test ! nice --1 echo foo > /dev/null 2>&1; then
   NOHUP_NICENESS="nohup"
 else
   NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup"
 fi
 
-
 export MYSQL_UNIX_PORT
 #export MYSQL_TCP_PORT
 touch $err_log; chown $user $err_log