From nobody@FreeBSD.org  Thu Jun 14 03:29:40 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 3899A106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 03:29:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [69.147.83.34])
	by mx1.freebsd.org (Postfix) with ESMTP id 228D38FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 03:29:40 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E3TdSl092145
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 14 Jun 2012 03:29:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5E3Tdfa092144;
	Thu, 14 Jun 2012 03:29:39 GMT
	(envelope-from nobody)
Message-Id: <201206140329.q5E3Tdfa092144@red.freebsd.org>
Date: Thu, 14 Jun 2012 03:29:39 GMT
From: Tassilo Philipp <tphilipp@potion-studios.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /etc/rc.subr not checking some scripts (e.g. ruby running 'thin')
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169047
>Category:       conf
>Synopsis:       [rc.subr] [patch] /etc/rc.subr not checking some scripts (e.g. ruby running 'thin')
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 14 03:30:05 UTC 2012
>Closed-Date:    
>Last-Modified:  Tue Mar 11 11:20:00 UTC 2014
>Originator:     Tassilo Philipp
>Release:        9-RELEASE
>Organization:
>Environment:
FreeBSD ebenholz 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
I wrote a rc.d script to handle 'thin' processes on startup, however I couldn't stop it using "/etc/rc.d/thin stop". Check /etc/rc.subr, I noticed that "find_processes" looks for something in the ps output like:

5570      0 ruby19: /usr/local/bin/thin server (0.0.0.0:80) (ruby19)

whereas in my case, it is:

5570      0 ruby19: thin server (0.0.0.0:80) (ruby19)

Find attached a patch that would fix the problem.

For reference, here is my /etc/rc.d/thin:
---------------->
#!/bin/sh
#

# PROVIDE: thin
# REQUIRE: DAEMON
# BEFORE: LOGIN

. /etc/rc.subr

# Defaults.
thin_enable=${thin_enable:-"NO"}

name=thin
rcvar=thin_enable
app_path=/var/www/grecLeFroc

command="/usr/local/bin/${name}"
command_args="start -d -c ${app_path}/current -p 80 -e production"
command_interpreter="/usr/local/bin/ruby19"

pidfile="${app_path}/shared/pids/${name}.pid"

# Crucial (!) for execjs to find js runtime.
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin

load_rc_config $name
run_rc_command "$1"
<----------------
>How-To-Repeat:

>Fix:
--- /etc/rc.subr.orig   2012-06-14 11:01:14.000000000 -0500
+++ /etc/rc.subr    2012-06-14 11:01:33.000000000 -0500
@@ -323,9 +323,10 @@
        fi
        _interp="$* $_procname"     # cleanup spaces, add _procname
        _interpbn=${1##*/}
+       _procnamebn=${_procname##*/}
        _fp_args='_argv'
        _fp_match='case "$_argv" in
-           ${_interp}|"${_interp} "*|"${_interpbn}: ${_procname}"*)'
+           ${_interp}|"${_interp} "*|"${_interpbn}: ${_procnamebn}"*|"${_interpbn}: ${_procname}"*)'
    else                    # a normal daemon
        _procnamebn=${_procname##*/}
        _fp_args='_arg0 _argv'

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Jun 17 22:35:47 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169047 

From: Geoff Garside <geoff@geoffgarside.co.uk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/169047: [rc.subr] [patch] /etc/rc.subr not checking some scripts (e.g. ruby running &#39;thin&#39;)
Date: Tue, 11 Mar 2014 11:09:44 +0000

 --Apple-Mail=_F02A976E-F0B6-41CE-8C46-5ABE5FA588FE
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 Heres an updated copy of the patch if that helps.
 
 
 --Apple-Mail=_F02A976E-F0B6-41CE-8C46-5ABE5FA588FE
 Content-Disposition: attachment;
 	filename=etc-rc.subr.patch.txt
 Content-Type: text/plain;
 	x-unix-mode=0644;
 	name="etc-rc.subr.patch.txt"
 Content-Transfer-Encoding: quoted-printable
 
 --- /etc/rc.subr.orig	2014-03-11 11:06:09.251438710 +0000
 +++ /etc/rc.subr	2014-03-11 11:07:29.172157233 +0000
 @@ -288,9 +288,10 @@
  		fi
  		_interp=3D"$* $_procname"		# cleanup =
 spaces, add _procname
  		_interpbn=3D${1##*/}
 +		_procnamebn=3D${_procname##*/}
  		_fp_args=3D'_argv'
  		_fp_match=3D'case "$_argv" in
 -		    ${_interp}|"${_interp} =
 "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*)'
 +		    ${_interp}|"${_interp} =
 "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*|"${_interpbn}: =
 ${_procnamebn}"*)'
  	else					# a normal daemon
  		_procnamebn=3D${_procname##*/}
  		_fp_args=3D'_arg0 _argv'
 
 --Apple-Mail=_F02A976E-F0B6-41CE-8C46-5ABE5FA588FE--

From: Geoff Garside <geoff@geoffgarside.co.uk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/169047: [rc.subr] [patch] /etc/rc.subr not checking some scripts (e.g. ruby running &#39;thin&#39;)
Date: Tue, 11 Mar 2014 11:04:22 +0000

 Any idea when this might get included, its not in FreeBSD 10-RELEASE.
>Unformatted:
