Bug #64342 init.d mysql script created by mysql Solaris package fails to run due to pidof
Submitted: 15 Feb 2012 15:13 Modified: 7 Dec 2016 16:45
Reporter: Daniel Bunford-Jones Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:5.5.20, 5.5.23, 5.6.24, 5.6.25 OS:Solaris (9/10)
Assigned to: CPU Architecture:Any
Tags: /etc/init.d/mysql, mysql.server, PACKAGE, pidof, solaris

[15 Feb 2012 15:13] Daniel Bunford-Jones
Description:
init.d mysql script generated by the mysql Solaris PKG fails due to use of pidof.

The bug exists in solaris package file mysql/reloc/mysql/support-files/mysql.server, which is copied as /etc/init.d/mysql via the postinstall script.

The mysql/reloc/mysql/support-files/mysql.server script calls "pidof" (https://en.wikipedia.org/wiki/Pidof) command that does not exist in Solaris.  The equivalent command in solaris is pgrep.

How to repeat:
pkgadd -d ./mysql-5.5.20-solaris10-x86_64.pkg
/etc/init.d/mysql status

Suggested fix:
Modify the script, excerpt below:

...
# Try to find appropriate mysqld process
      mysqld_pid=`pidof $libexecdir/mysqld`
      if test -z $mysqld_pid ; then
...

Change to:

...
# Try to find appropriate mysqld process
      mysqld_pid="`pgrep -d' ' $libexecdir/mysqld`"
      if test -z "${mysqld_pid}" ; then
...
[22 Feb 2012 9:47] Valeriy Kravchuk
Thank you for the problem report. Verified by code review:

[openxs@chief 5.5]$ grep -rn pidof *
support-files/mysql.server:362:      mysqld_pid=`pidof $libexecdir/mysqld`
[openxs@chief 5.5]$ grep -rn pgrep *
[openxs@chief 5.5]$

pidof is used unconditionally, for all kinds of OSes.
[25 Jun 2015 12:36] Daniel Bunford-Jones
The bug is still present in 5.6.25.   Please can this be resolved either by branching the versions based on OS type, or adding a conditional statement to the init script e.g.

case "`uname -s`" in
  "SunOS")
     mysqld_pid=`pgrep -d' ' $libexecdir/mysqld`
   ;;
  "Linux")
     mysqld_pid=`pidof $libexecdir/mysqld`
   ;;
esac

Thanks
[7 Dec 2016 16:45] Paul DuBois
Posted by developer:
 
Noted in 5.5.55, 5.6.36, 5.7.18, 8.0.1 changelogs.

On non-Linux Unix systems, the mysql.server startup script used the
Linux command pidof rather than pgrep.