Subject: Re: "fixing" the network shutdown problems with rc.d
To: None <tech-userlevel@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: tech-userlevel
Date: 04/26/2000 09:33:13
Just to come back to this after a reminder on current-users:
A proposed change is to use "shutdown" as the argument when the system
is coming down. In most cases, "shutdown" will be ignored since most
things don't need to be killed of in a special way - what init does
is good enough. The patch provides a way for xdm to handle shutdown.
I'm not really sure that it's necessary for xdm, but it was in the old
/etc/rc.shutdown and provides an example of how to do things.
Simon Burge wrote:
> David Brownlee wrote:
>
> > It works well for NetBSD scripts, but what about people dropping
> > in third party rc.d scripts?
> >
> > One not entirely clean option might be to set 'RC_SHUTDOWN' in
> > the environment and run with a "stop" arg, and the scripts can
> > key off that.
> >
> > No perfect solution :(
> >
> > I'm probably inclined to keep "shutdown" as its cleaner, but we
> > need to be aware of the third part issue...
>
> My first thought was maybe go back to the IGNORES idea I started
> with, but third party scripts already need to be modified to handle
> PROVIDES/REQUIRES, so adding shutdown handling may not be too bad. As
> Robert Elz said, the set of scripts that actually require shutdown
> processing is quite small (typically databases).
One more thing - probably most all scripts that get dropped into
/etc/rc.d would be modified anyways. And if this is handled by the
package system then the changes can easily be managed.
Simon.
--
Index: rc.shutdown
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.shutdown,v
retrieving revision 1.3
diff -p -u -r1.3 rc.shutdown
--- rc.shutdown 2000/03/10 13:17:25 1.3
+++ rc.shutdown 2000/04/25 23:06:07
@@ -31,7 +31,7 @@ done
files=$nfiles
for i in $files; do
- run_rc_script $i stop
+ run_rc_script $i shutdown
done
date
Index: rc.subr
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.subr,v
retrieving revision 1.13
diff -p -u -r1.13 rc.subr
--- rc.subr 2000/04/22 03:01:22 1.13
+++ rc.subr 2000/04/25 23:06:07
@@ -155,8 +155,8 @@ check_process()
#
# run_rc_command arg [supported_args]
-# Scan supported_args (which has "start stop restart rcvar status"
-# prepended) for arg.
+# Scan supported_args (which has "start stop restart rcvar status
+# shutdown" prepended) for arg.
# If there's a match, run ${arg}_cmd or the default command (see below).
#
# If arg has a given prefix, then:
@@ -216,6 +216,7 @@ check_process()
# else
# kill $sig_stop `check_process $command`
# $sig_stop defaults to TERM.
+# shutdown Nothing.
# reload As stop, except use $sig_reload instead.
# $sig_reload defaults to HUP.
# restart Run `stop' then `start'.
@@ -244,7 +245,7 @@ run_rc_command()
;;
esac
- _keywords="start stop restart rcvar $*"
+ _keywords="start stop restart rcvar shutdown $*"
_pidcmd=
if [ -z "$_rc_fast_run" ]; then
if [ -n "$pidfile" ]; then
@@ -346,6 +347,10 @@ run_rc_command()
eval $_precmd || return 1
echo "Stopping ${name}."
kill -${sig_stop:-TERM} $_pid
+ ;;
+
+ shutdown)
+ # ignored
;;
reload)
Index: rc.d/xdm
===================================================================
RCS file: /cvsroot/basesrc/etc/rc.d/xdm,v
retrieving revision 1.2
diff -p -u -r1.2 xdm
--- xdm 2000/03/13 04:04:10 1.2
+++ xdm 2000/04/25 23:06:07
@@ -14,4 +14,11 @@ command="/usr/X11R6/bin/${name}"
pidfile="/var/run/${name}.pid"
required_files="/usr/X11R6/lib/X11/xdm/xdm-config"
+shutdown_cmd="xdm_shutdown"
+
+xdm_shutdown()
+{
+ run_rc_command stop
+}
+
run_rc_command "$1" "reload"