Bug #8046 --mysqld of mysqld_safe must contain substring "mysqld"
Submitted: 20 Jan 2005 14:14 Modified: 20 Apr 2005 7:33
Reporter: Jianhong Feng Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:4.1.8 OS:Solaris (Solaris, Linux)
Assigned to: Jani Tolonen CPU Architecture:Any

[20 Jan 2005 14:14] Jianhong Feng
Description:
mysqld_safe has the command line option --mysqld=XXX, which supposes to be the file prefix of mysqld. However, the following code in mysqld has the name hard-coded: 

# If there exists an old pid file, check if the daemon is already running
# Note: The switches to 'ps' may depend on your operating system
if test -f $pid_file
then
  PID=`cat $pid_file`
  if /usr/bin/kill -0 $PID > /dev/null 2> /dev/null
  then
    if /usr/bin/ps -p $PID | grep mysqld > /dev/null 
    then    # The pid contains a mysqld process
      echo "A mysqld process already exists"
      echo "A mysqld process already exists at " `date` >> $err_log
      exit 1
    fi
  fi
  # [code snipped]
fi

How to repeat:
1. Rename mysqld to sqld
2. Run "mysqld_safe --defaults-file=/some/foo --mysqld=/full/path/to/sqld &"
    (foo is a valid my.cnf file, content not quite relevant for this bug)
    Remember the process id of mysqld_safe.
3. kill -9 <pid>
    pid is the process id of mysqld_safe in step 2.
    mysqld should still running (as expected).
4. Re-run "mysqld_safe --defaults-file=/some/foo --mysqld=/full/path/to/sqld &"
    Instead of reporting "A mysqld process already exists" (and exit), 
    mysqld_safe says 

# Checking tables in ...
Starting sqld daemon with databases from ...
STOPPING server from pid file ...
050120 14:39:19  mysqld ended

    But the mysqld was not killed by mysqld_safe.

Suggested fix:
Replace the line

    if /usr/bin/ps -p $PID | grep mysqld > /dev/null 

by

    if /usr/bin/ps -p $PID | grep $MYSQLD > /dev/null
[20 Apr 2005 7:33] Jani Tolonen
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Fixed into 5.0.
[20 Apr 2005 7:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/24160