Send signal to every process in the same process group

When stopping a run/task/service we must send SIGTERM/KILL to all every
process in the same process group.  Otherwise we may end up with stray
processes like 'logit' when log redirection is enabled.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-04-08 18:00:48 +02:00
parent 9b022ed7a4
commit 91a9c83928
+2 -2
View File
@@ -476,7 +476,7 @@ static void service_kill(svc_t *svc)
if (runlevel != 1)
print_desc("Killing ", svc->desc);
kill(svc->pid, SIGKILL);
kill(-svc->pid, SIGKILL);
/* Let SIGKILLs stand out, show result as [WARN] */
if (runlevel != 1)
@@ -539,7 +539,7 @@ static int service_stop(svc_t *svc)
if (svc->pid <= 1)
goto cleanup;
res = kill(svc->pid, svc->sighalt);
res = kill(-svc->pid, svc->sighalt);
/* PID lost or forking process never really started */
if (res == -1 && ESRCH == errno) {