start-stop-daemon: don't fail stopping if pidfile is gone

If pidfile does not exist when we are stopping the daemon, assume it is
already stopped, and report success.

hostapd is an example of a daemon which removes its pidfile when it is
exiting. If this daemon terminates prematurely, that is, without s-s-d
involvement, then openrc fails to restart it, because s-s-d "stop"
command fails when pidfile is missing.

X-Gentoo-Bug: 646274
X-Gentoo-Bug-URL: https://bugs.gentoo.org/646274
This commit is contained in:
Andrey Utkin 2018-04-21 23:13:15 +01:00 committed by William Hubbs
parent f4e2142089
commit 0200002b8c

View File

@ -661,7 +661,7 @@ int main(int argc, char **argv)
parse_schedule(applet, NULL, sig);
if (pidfile) {
pid = get_pid(applet, pidfile);
if (pid == -1)
if (pid == -1 && errno != ENOENT)
exit(EXIT_FAILURE);
} else {
pid = 0;