Subject: Clean shutdown of services in /etc/rc.d
To: None <tech-userlevel@netbsd.org>
From: =?iso-8859-1?q?Gr=E9goire=20Sutre?= <sutre@labri.fr>
List: tech-userlevel
Date: 11/03/2003 18:54:49
Hi,
I'm not sure whether this is the right place to post this suggestion, so=20
please forgive me if it's not... I'm running NetBSD 1.6.1_STABLE by the w=
ay.
I'm trying to fix the default "/etc/rc.d/dhclient stop" behavior, so that=
=20
instead of killing dhclient, dhclient -r is tried first. Indeed, calling=
=20
dhclient -r seems to allow dhclient to revert some modifications it did w=
hen=20
it was started (for instance restoring resolv.conf which was backed up).
See: http://news.gw.com/netbsd.help/26336
I believe it would be nice if a service file could tell, using a variable=
,=20
how to cleanly shutdown itself. This variable would be of the same kind a=
s=20
stop_precmd or stop_cmd, so it could be called for instance "stop_cleancm=
d".
This way, in /etc/rc.d/dhclient, one could add a line:
stop_cleancmd=3D"/sbin/dhclient -r"
and rc.subr's run_rc_command() function would (in the "stop" case) at som=
e=20
point check whether stop_cleancmd is defined, and if it is defined, first=
try=20
stop_clean and, if that did not stop the service, then try to kill it:
if "service is running" then
if "stop_cleancmd is defined" then
do stop_cleancmd
if "service is still running" then
do "kill the service"
fi
else
do "kill the service"
fi
fi
=20
If you think this stuff could be useful, I can try to write a patch for i=
t.
Thanks for your reading and comments,
Gregoire.