]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
monitor: send SIGTERM to the container when SIGHUP is received
authorTycho Andersen <tycho@tycho.ws>
Mon, 5 Feb 2018 14:17:48 +0000 (14:17 +0000)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 6 Feb 2018 12:36:51 +0000 (13:36 +0100)
For the ->execute() case, we want to make sure the application dies when
SIGHUP is received. The next patch will ignore SIGHUP in the lxc monitor,
because tasks inside the container send SIGHUP to init to have it reload
its config sometimes, and we don't want to do that with init.lxc, since it
might actually kill the container if it forwards SIGHUP to the child and
the child can't handle it.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
src/lxc/start.c

index 721dda3c664d2bdd865350f9dda17e6814b5d987..5c567fef982103c3beb58001cb5e46087712ffe2 100644 (file)
@@ -336,6 +336,12 @@ static int signal_handler(int fd, uint32_t events, void *data,
                }
        }
 
+       if (siginfo.ssi_signo == SIGHUP) {
+               kill(hdlr->pid, SIGTERM);
+               INFO("Killing %d since terminal hung up", hdlr->pid);
+               return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
+       }
+
        /* More robustness, protect ourself from a SIGCHLD sent
         * by a process different from the container init.
         */