diff options
author | June McEnroe <june@causal.agency> | 2020-08-16 00:27:08 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-08-16 00:27:08 -0400 |
commit | 3fbe9b593321b0bd744b295cc543a0dd87142c86 (patch) | |
tree | e028e59d248a247cac520ab4b98785ef4d69cad5 | |
parent | Set title after reload (diff) | |
download | catsit-3fbe9b593321b0bd744b295cc543a0dd87142c86.tar.gz catsit-3fbe9b593321b0bd744b295cc543a0dd87142c86.zip |
Use process groups for services
This lets us properly signal services with child processes of their own.
-rw-r--r-- | service.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/service.c b/service.c index 63a647c..ec7ac68 100644 --- a/service.c +++ b/service.c @@ -174,6 +174,7 @@ void serviceStart(struct Service *service) { return; } + setpgid(0, 0); dup2(service->outPipe[1], STDOUT_FILENO); dup2(service->errPipe[1], STDERR_FILENO); @@ -207,10 +208,10 @@ void serviceStart(struct Service *service) { void serviceSignal(struct Service *service, int signal) { if (service->state != Start) return; - int error = kill(service->pid, signal); + int error = killpg(service->pid, signal); if (error) { syslog( - LOG_WARNING, "kill(%s[%d], %s): %m", + LOG_WARNING, "killpg(%s[%d], %s): %m", service->name, service->pid, sys_signame[signal] ); } |