From: Tycho Andersen Date: Mon, 5 Feb 2018 14:17:48 +0000 (+0000) Subject: monitor: send SIGTERM to the container when SIGHUP is received X-Git-Tag: lxc-3.0.0.beta1~54^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4b5d7a8b418a14f6f97bc00df9b529eb09ea4f8;p=thirdparty%2Flxc.git monitor: send SIGTERM to the container when SIGHUP is received 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 --- diff --git a/src/lxc/start.c b/src/lxc/start.c index d79fbe239..ab928a91d 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -345,6 +345,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. */