mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 17:12:32 +07:00
Follow-up to 7dc7f9a, protect against stalling on non-existing pids
A forking service, e.g. a SysV init script, that returns is no longer running, even though the monitored service may still be starting. We must mark the svc->pid as terminated until we know more -- otherwise we may stall on a shutdown at that exact point. Also, when shutting down, and stopping all services, ensure we do not start the carousel for non-existing PIDs. This might also cause our stalling at shutdown. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+11
-1
@@ -747,6 +747,14 @@ static int service_stop(svc_t *svc)
|
||||
*/
|
||||
svc_started(svc);
|
||||
|
||||
/*
|
||||
* Verify there's still something there before we send the reaper.
|
||||
*/
|
||||
if (svc->pid > 1 && !pid_alive(svc->pid)) {
|
||||
svc->pid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!svc->desc[0])
|
||||
do_progress = 0;
|
||||
|
||||
@@ -1501,8 +1509,10 @@ void service_monitor(pid_t lost, int status)
|
||||
}
|
||||
|
||||
/* Forking sysv/services declare themselves with pid:!/path/to/pid.file */
|
||||
if (svc_is_starting(svc) && svc_is_forking(svc))
|
||||
if (svc_is_starting(svc) && svc_is_forking(svc)) {
|
||||
svc->pid = 0; /* Expect no more activity from this one */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Terminate any children in the same proess group, e.g. logit */
|
||||
kill(-svc->pid, SIGKILL);
|
||||
|
||||
Reference in New Issue
Block a user