From 6fd1668e7f96c15b8688a0fa955e2c10bbc4785d Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Tue, 13 Jul 2010 14:51:45 +0200 Subject: [PATCH] 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 --- src/lxc/lxc_init.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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)