Me mode: make init reap zombie processes
authorRobert Swiecki <robert@swiecki.net>
Wed, 14 Jun 2017 00:15:11 +0000 (02:15 +0200)
committerRobert Swiecki <robert@swiecki.net>
Wed, 14 Jun 2017 00:15:11 +0000 (02:15 +0200)
pid.c

diff --git a/pid.c b/pid.c
index 191c0761791bb1f58a06e818e5c5889649626fe4..25694d6af85844ff44bfbe94e08e806e47baab03 100644 (file)
--- a/pid.c
+++ b/pid.c
@@ -50,6 +50,18 @@ bool pidInitNs(struct nsjconf_t *nsjconf)
        if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) == -1) {
                PLOG_W("(prctl(PR_SET_PDEATHSIG, SIGKILL) failed");
        }
+
+       /* Act sort-a like a init by reaping zombie processes */
+       struct sigaction sa = {
+               .sa_handler = SIG_DFL,
+               .sa_flags = SA_NOCLDWAIT | SA_NOCLDSTOP,
+               .sa_restorer = NULL,
+       };
+       sigemptyset(&sa.sa_mask);
+       if (sigaction(SIGSTOP, &sa, NULL) == -1) {
+               PLOG_W("Couldn't set sighandler for SIGSTOP");
+       }
+
        for (;;) {
                pause();
        }