]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-init kills all processes with SIGTERM
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 13 Jul 2010 12:51:45 +0000 (14:51 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 13 Jul 2010 12:51:45 +0000 (14:51 +0200)
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 <dlezcano@fr.ibm.com>
src/lxc/lxc_init.c

index 5e0da5eef76b02d0ee4ee5d811455b1f8c714398..d91a3a10d8e944e426f97e78aaa752ce6f4a6edc 100644 (file)
@@ -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)