mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00: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:
1 parent
bbaa7a1403
commit
9f50b033d9
1 file changed
+7
-1
+7
-1
@@ -358,10 +358,16 @@ static void service_kill(svc_t *svc)
|
|||||||
{
|
{
|
||||||
service_timeout_cancel(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)
|
if (runlevel != 1)
|
||||||
print_desc("Killing ", svc->desc);
|
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);
|
kill(svc->pid, SIGKILL);
|
||||||
|
|
||||||
/* Let SIGKILLs stand out, show result as [WARN] */
|
/* Let SIGKILLs stand out, show result as [WARN] */
|
||||||
|
|||||||
Reference in new issue
Block a user