From nobody@FreeBSD.org  Mon Jan 12 11:13:54 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 34A6E1065B63
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Jan 2009 11:13:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id F161A8FC30
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Jan 2009 11:13:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n0CBDr6e052667
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Jan 2009 11:13:53 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n0CBDrnB052666;
	Mon, 12 Jan 2009 11:13:53 GMT
	(envelope-from nobody)
Message-Id: <200901121113.n0CBDrnB052666@www.freebsd.org>
Date: Mon, 12 Jan 2009 11:13:53 GMT
From: Dominic Fandrey <kamikaze@bsdforen.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: rc services started with onestart are not stopped upon shutdown
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         130414
>Category:       conf
>Synopsis:       [patch] rc services started with onestart are not stopped upon shutdown
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 12 11:20:02 UTC 2009
>Closed-Date:    Sat May 08 22:20:12 UTC 2010
>Last-Modified:  Sat May 08 22:20:12 UTC 2010
>Originator:     Dominic Fandrey
>Release:        RELENG_7
>Organization:
private
>Environment:
FreeBSD mobileKamikaze.norad 7.1-STABLE FreeBSD 7.1-STABLE #1: Tue Jan  6 22:28:13 CET 2009     root@mobileKamikaze.norad:/usr/obj/HP6510b/amd64/usr/src/sys/HP6510b  amd64
>Description:
On development machines I often start services with onestart (e.g. /usr/local/etc/rc.d apache22 onestart). I do not set rcvar for these services, because I only require them for testing and development.

The appended fix makes sure that the rc commands are executed without rcvar set if the service is running. This ensures the execution of the stop_cmd during system shutdown and makes the status and stop commands work without the one or force prefix.

I have so far not stumbled over any problems caused by this.
>How-To-Repeat:

>Fix:
--- src/etc/rc.subr.orig	2009-01-12 11:40:37.000000000 +0100
+++ src/etc/rc.subr	2009-01-12 12:00:16.000000000 +0100
@@ -603,19 +603,19 @@
 		fi
 	fi
 
+	eval $_pidcmd			# determine the pid
+
 					# if ${rcvar} is set, and $1 is not
 					# "rcvar", then run
 					#	checkyesno ${rcvar}
 					# and return if that failed
 					#
-	if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then
+	if [ -z "$rc_pid" -a -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then
 		if ! checkyesno ${rcvar}; then
 			return 0
 		fi
 	fi
 
-	eval $_pidcmd			# determine the pid if necessary
-
 	for _elem in $_keywords; do
 		if [ "$_elem" != "$rc_arg" ]; then
 			continue


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Mon Jan 12 12:22:14 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s) 

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

From: Dominic Fandrey <kamikaze@bsdforen.de>
To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de
Cc:  
Subject: Re: conf/130414: [patch] rc services started with onestart are not
 stopped upon shutdown
Date: Sat, 14 Feb 2009 23:34:38 +0100

 I've been using that for a month, now and it solves more
 problems for me than I actually had in mind without causing
 any problems.
 
 I really want to see this committed. Is there any reason not
 to do so?

From: Dominic Fandrey <kamikaze@bsdforen.de>
To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de
Cc:  
Subject: Re: conf/130414: [patch] rc services started with onestart are not
 stopped upon shutdown
Date: Fri, 03 Jul 2009 09:28:25 +0200

 ping
 
 Please commit or close.
 
 I've been using this patch for 6 months now.
 Consider it very well tested.
 
 It stops postgres, apache and my vpnc
 connections upon shutdown. Especially that is useful,
 because if they are not shutdown properly I'm not
 allowed to log back in for 30 minutes.

From: Dominic Fandrey <kamikaze@bsdforen.de>
To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de
Cc:  
Subject: Re: conf/130414: [patch] rc services started with onestart are not
 stopped upon shutdown
Date: Sat, 10 Apr 2010 11:23:37 +0200

 Here is an improved version of the patch, that simply skips
 checkyesno ${rcvar}
 if the process is running. This way, each running service
 will be treated as if <service>_enable="YES" is set, which
 ensures proper shutdown treatment and generally more
 convenient handling or services.
 
 
 diff -u rc.subr.orig rc.subr
 --- rc.subr.orig	2010-04-10 11:09:28.000000000 +0200
 +++ rc.subr	2010-04-10 11:21:06.000000000 +0200
 @@ -660,12 +660,12 @@
  		if [ "$_elem" != "$rc_arg" ]; then
  			continue
  		fi
 -					# if ${rcvar} is set, and $1 is not
 -					# "rcvar", then run
 +					# if ${rcvar} is set, $1 is not "rcvar"
 +					# and ${rc_pid} is not set, then run
  					#	checkyesno ${rcvar}
  					# and return if that failed
  					#
 -		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then
 +		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a -z "${rc_pid}" ]; then
  			if ! checkyesno ${rcvar}; then
  				if [ -n "${rc_quiet}" ]; then
  					return 0

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/130414: commit references a PR
Date: Thu, 15 Apr 2010 21:18:37 +0000 (UTC)

 Author: dougb
 Date: Thu Apr 15 21:18:24 2010
 New Revision: 206686
 URL: http://svn.freebsd.org/changeset/base/206686
 
 Log:
   If a service is running, make 'stop' work even if ${name}_enable
   is not set.
   
   PR:		conf/130414
   Submitted by:	Dominic Fandrey <kamikaze@bsdforen.de>
   Reviewed by:	freebsd-rc@
 
 Modified:
   head/etc/rc.subr
 
 Modified: head/etc/rc.subr
 ==============================================================================
 --- head/etc/rc.subr	Thu Apr 15 20:48:57 2010	(r206685)
 +++ head/etc/rc.subr	Thu Apr 15 21:18:24 2010	(r206686)
 @@ -646,12 +646,12 @@ run_rc_command()
  		if [ "$_elem" != "$rc_arg" ]; then
  			continue
  		fi
 -					# if ${rcvar} is set, and $1 is not
 -					# "rcvar", then run
 +					# if ${rcvar} is set, $1 is not "rcvar"
 +					# and ${rc_pid} is not set, then run
  					#	checkyesno ${rcvar}
  					# and return if that failed
  					#
 -		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then
 +		if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a -z "${rc_pid}" ]; then
  			if ! checkyesno ${rcvar}; then
  				if [ -n "${rc_quiet}" ]; then
  					return 0
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: dougb 
State-Changed-When: Thu Apr 15 21:20:43 UTC 2010 
State-Changed-Why:  

The change has been committed to HEAD. I will MFC it after it has had 
time to settle, but ideally before 8.1-RELEASE. 


Responsible-Changed-From-To: freebsd-rc->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Thu Apr 15 21:20:43 UTC 2010 
Responsible-Changed-Why:  

I'll handle the MFC. 

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

From: Dominic Fandrey <kamikaze@bsdforen.de>
To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de
Cc:  
Subject: Re: conf/130414: [patch] rc services started with onestart are not
 stopped upon shutdown
Date: Mon, 19 Apr 2010 14:58:23 +0200

 I'm really glad this is progressing, thank you very much!
State-Changed-From-To: patched->closed 
State-Changed-By: dougb 
State-Changed-When: Sat May 8 22:17:13 UTC 2010 
State-Changed-Why:  

This has now been merged to RELENG_[78], I'm not going to merge it 
to RELENG_6 for 2 reasons, the most important being that there will 
not be a new release on that branch and we'd like to encourage folks 
to move on. The other reason is that merging it to RELENG_7 required 
merging another, very old (2008) change that was worth merging anyway, 
but is a degree of complexity that we usually try to avoid in the 
older branches. 

Meanwhile, thanks again both for this suggestion, the patch, and 
perhaps more importantly, your persistence. :) 


Regards, 

Doug 

http://www.freebsd.org/cgi/query-pr.cgi?pr=130414 
>Unformatted:
