From 91a9c83928349a9c36acf34b1d2f222328a06a1d Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 8 Apr 2020 18:00:46 +0200 Subject: [PATCH] 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 --- src/service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service.c b/src/service.c index d9ee43e6..b7c9bc2e 100644 --- a/src/service.c +++ b/src/service.c @@ -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) {