Subject: Re: Clean shutdown of services in /etc/rc.d
To: Luke Mewburn <lukem@NetBSD.org>
From: =?iso-8859-1?q?Gr=E9goire=20Sutre?= <sutre@labri.fr>
List: tech-userlevel
Date: 11/06/2003 20:54:51
> As a side issue, is there any reason we don't always run "dhclient -r"
> when "stop"ping dhclient?

When I put the line stop_cmd=3D"$command -r" in /etc/rc.conf.d/dhclient, =
and if=20
dhclient is not running, then "/etc/rc.d/dhclient stop" gives the followi=
ng:

- if dhclient has not been started at all (no pid file):

	cat: /var/run/dhclient.pid: No such file or directory
	usage: kill [-s signal_name] pid ...
	       kill -l [exit_status]
	       kill -signal_name pid ...
	       kill -signal_number pid ...
	Internet Software Consortium DHCP Client V3.0rc10
	Copyright 1995-2001 Internet Software Consortium.
	All rights reserved.
	For info, please visit http://www.isc.org/products/DHCP

	Sending on   Socket/fallback


- if dhclient has been started and stopped (a pid file still exists):

	kill: 1573: No such process
	Internet Software Consortium DHCP Client V3.0rc10
	Copyright 1995-2001 Internet Software Consortium.
	All rights reserved.
	For info, please visit http://www.isc.org/products/DHCP

	Sending on   Socket/fallback


This is of course not a big problem, but I'd rather get the (usual) messa=
ge:

dhclient not running? (check /var/run/dhclient.pid).

that is printed when I don't specify any "stop_cmd" command for dhclient =
(but=20
then, /etc/resolv.conf is not restored...).


Maybe it is dhclient's job to check wether it is running before trying to=
=20
read /var/run/dhclient.pid and kill itself (I have no clue about this).


>   | I believe it would be nice if a service file could tell, using a
>   | variable, how to cleanly shutdown itself. This variable would be of=
 the
>   | same kind as stop_precmd or stop_cmd, so it could be called for
>   | instance "stop_cleancmd".
>
> That's what "stop" is for.
> I'm not (yet) convinced that there's a need for yet more "kitchen sink"
> functionality in rc.subr(8) for what is at best a single special case.

I trust you, as I'm new to NetBSD.  This was only an humble suggestion :-=
)

Cheers,

Gregoire.