threads/85161: rcng scripts for processes running as kernel threads not working cause of [procname]

Andy Hilker ah at crypta.net
Sat Aug 20 17:40:14 GMT 2005


>Number:         85161
>Category:       threads
>Synopsis:       rcng scripts for processes running as kernel threads not working cause of [procname]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 20 17:40:12 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Andy Hilker
>Release:        5.4-RELEASE-p3
>Organization:
>Environment:
FreeBSD mypc 5.4-RELEASE-p3 FreeBSD 5.4-RELEASE-p3 #6: Tue Jul  5 16:48:52 CEST 2005     root at arkona:/usr/obj/usr/src/sys/MYPC  i386
>Description:
If you run a process which is using kernel threads (like mysqld from ports) the ps utility shows procnames like [procname]:

mypc:/# ps -auxw | grep sql
root    22885  0.0  0.0  1584   964  p0  S+    7:14PM   0:00.00 grep sql
mysql    7204  0.0  0.0  1776   224  p2- IJ   11Aug05   0:00.02 [sh]
mysql    7240  0.0  0.9 67560 33304  p2- SJ   11Aug05   9:52.96 [mysqld]

The problem is, that you can not use 
procname="[mysqld]"
in your rcng script like /usr/local/etc/rc.d/mysqld-server.sh.

Because of this, rcng script functions like status, stop, restart are not working. Process is not find, pidnumber is not enough.
The behaviour is defined in /etc/rc.subr, line 267.
>How-To-Repeat:
see full description.      
>Fix:
correct handling of procname variable in /etc/rc.subr with escaping?
Below patch works, but maybe a shell scripting guru would make it better...

# $FreeBSD: src/etc/rc.subr,v 1.31.2.1 2005/01/17 11:51:00 keramida Exp $
--- rc.subr     Thu Aug 11 15:18:52 2005
+++ /etc/rc.subr        Thu Aug 11 15:14:06 2005
@@ -267,7 +267,7 @@
                _procnamebn=${_procname##*/}
                _fp_args='_arg0 _argv'
                _fp_match='case "$_arg0" in
-                   $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")'
+                   "$_procname"|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")'
        fi
 
        _proccheck='

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-threads mailing list