From: Daniel Lezcano Date: Tue, 13 Jul 2010 12:51:45 +0000 (+0200) Subject: lxc-init kills all processes with SIGTERM X-Git-Tag: lxc-0.7.2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fd1668e7f96c15b8688a0fa955e2c10bbc4785d;p=thirdparty%2Flxc.git lxc-init kills all processes with SIGTERM When lxc-init receives a SIGTERM, let's kill all the processes of the pid namespace with kill -1. So the exit of the container will happen gracefully with processes death cascade. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c index 5e0da5eef..d91a3a10d 100644 --- a/src/lxc/lxc_init.c +++ b/src/lxc/lxc_init.c @@ -154,11 +154,21 @@ int main(int argc, char *argv[]) int orphan = 0; pid_t waited_pid; - if (was_interrupted) { + switch (was_interrupted) { + + case 0: + break; + + case SIGTERM: + kill(-1, SIGTERM); + break; + + default: kill(pid, was_interrupted); - was_interrupted = 0; + break; } + was_interrupted = 0; waited_pid = wait(&status); if (waited_pid < 0) { if (errno == ECHILD)