From owner-freebsd-threads@FreeBSD.ORG Sat Aug 20 17:40:13 2005 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF20A16A41F for ; Sat, 20 Aug 2005 17:40:13 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id ED48A43D55 for ; Sat, 20 Aug 2005 17:40:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j7KHeCZI012944 for ; Sat, 20 Aug 2005 17:40:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j7KHeCAl012943; Sat, 20 Aug 2005 17:40:12 GMT (envelope-from gnats) Resent-Date: Sat, 20 Aug 2005 17:40:12 GMT Resent-Message-Id: <200508201740.j7KHeCAl012943@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andy Hilker Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C551416A41F for ; Sat, 20 Aug 2005 17:31:22 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90BA643D46 for ; Sat, 20 Aug 2005 17:31:22 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j7KHVMuC020085 for ; Sat, 20 Aug 2005 17:31:22 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id j7KHVMCn020082; Sat, 20 Aug 2005 17:31:22 GMT (envelope-from nobody) Message-Id: <200508201731.j7KHVMCn020082@www.freebsd.org> Date: Sat, 20 Aug 2005 17:31:22 GMT From: Andy Hilker To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: threads/85161: rcng scripts for processes running as kernel threads not working cause of [procname] X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Aug 2005 17:40:14 -0000 >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@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: