mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
Abort service kill if already terminated, otherwise kill(0, SIGKILL)
This patch fixes a rather nasty bug in the SIGTERM+SIGKILL logic employed by Finit when stopping tasks, e.g. at a runlevel change. When a process terminates, after Finit having sent it SIGTERM, and the SIGKILL timer expires *before* the timer has been cancelled, then the timer callback would cause kill(0, SIGKILL). Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+7
-1
@@ -358,10 +358,16 @@ static void service_kill(svc_t *svc)
|
||||
{
|
||||
service_timeout_cancel(svc);
|
||||
|
||||
if (svc->pid <= 1) {
|
||||
/* Avoid killing ourselves or all processes ... */
|
||||
_d("%s: Aborting SIGKILL, already terminated.", svc->cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (runlevel != 1)
|
||||
print_desc("Killing ", svc->desc);
|
||||
|
||||
_d("Sending SIGKILL to pid:%d name:%s", svc->pid, pid_get_name(svc->pid, NULL, 0));
|
||||
_d("%s: Sending SIGKILL to pid:%d", pid_get_name(svc->pid, NULL, 0), svc->pid);
|
||||
kill(svc->pid, SIGKILL);
|
||||
|
||||
/* Let SIGKILLs stand out, show result as [WARN] */
|
||||
|
||||
Reference in New Issue
Block a user