Bug 130414 - [patch] rc services started with onestart are not stopped upon shutdown
Summary: [patch] rc services started with onestart are not stopped upon shutdown
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Doug Barton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-12 11:20 UTC by kamikaze
Modified: 2010-05-08 23:20 UTC (History)
0 users

See Also:


Attachments
file.diff (645 bytes, patch)
2009-01-12 11:20 UTC, kamikaze
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description kamikaze 2009-01-12 11:20:02 UTC
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.
Comment 1 Gavin Atkinson freebsd_committer freebsd_triage 2009-01-12 12:22:14 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Over to maintainer(s)
Comment 2 kamikaze 2009-02-14 22:34:38 UTC
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?
Comment 3 kamikaze 2009-07-03 08:28:25 UTC
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.
Comment 4 kamikaze 2010-04-10 10:23:37 UTC
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
Comment 5 dfilter service freebsd_committer 2010-04-15 22:18:37 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"
Comment 6 Doug Barton freebsd_committer 2010-04-15 22:20:43 UTC
State Changed
From-To: open->patched


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


Comment 7 Doug Barton freebsd_committer 2010-04-15 22:20:43 UTC
Responsible Changed
From-To: freebsd-rc->dougb


I'll handle the MFC.
Comment 8 kamikaze 2010-04-19 13:58:23 UTC
I'm really glad this is progressing, thank you very much!
Comment 9 Doug Barton freebsd_committer 2010-05-08 23:17:13 UTC
State Changed
From-To: patched->closed


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