quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit 094c8ba814f388dcefee403c4d369005a8d9810f
parent ba38b0969f542e6e7d3f01ba500189a81ca32355
Author: Dominik Schmidt <domischmidt@swissonline.ch>
Date:   Mon,  2 Jul 2018 02:08:08 +0000

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>.

Diffstat:
main.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

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