Incorrect service state is reported during shutdown on Windows
When a Windows service receives a request to stop, it should not set its state to SERVICE_STOPPED
until it is completely shut down as doing that allows the operating system to kill that service prematurely. In the case of named
, this may e.g. prevent the PID file and/or the lock file from being cleaned up.
Apparently named
has been doing this wrong for the past 18 years.
To reproduce:
-
Install
named
as a service usingBINDInstall.exe
. -
Put the following
named.conf
in place:options { directory "<path-to-some-writable-directory>"; pid-file "named.pid"; };
-
Start the "ISC BIND" service using the "Services" applet (
services.msc
). -
Stop the "ISC BIND" service using the "Services" applet.
Chances are (it is a race) that named.pid
will still be present in the working directory, even though it should not be. Also, the "exiting" message may not be logged.
By contrast, if named
is stopped using rndc stop
, shutdown always completes as intended.