Open a new process group before setting up signal handler

When cleaning up after a caught signal, quark forwards the signal to all
processes in the process group with `kill(0, ...)`. If we do not open up a new
process group in the parent process, quarks parent will be sent a SIG... too,
resulting it to shut down (especially considering that the parent process might
run as root).

As a result, if we set up the service with djb's excellent daemontools,
`svc -d quark` will terminate the svscan-process and tear all other services
down with it.

See also <https://cr.yp.to/daemontools/faq/create.html#pgrphack>.
This commit is contained in:
Dominik Schmidt 2018-07-02 02:08:08 +00:00 committed by Laslo Hunhold
parent ba38b0969f
commit 094c8ba814

3
main.c
View file

@ -240,6 +240,9 @@ main(int argc, char *argv[])
"Entry not found"); "Entry not found");
} }
/* Open a new process group */
setpgid(0,0);
handlesignals(sigcleanup); handlesignals(sigcleanup);
/* bind socket */ /* bind socket */