[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lxc-devel
Subject:    [lxc-devel] [patch -lxc 3/4] lxc-init kills all processes with SIGTERM
From:       dlezcano () fr ! ibm ! com (Daniel Lezcano)
Date:       2010-07-15 21:08:17
Message-ID: 1279228098-23784-3-git-send-email-dlezcano () fr ! ibm ! com
[Download RAW message or body]

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 at fr.ibm.com>
---
 src/lxc/lxc_init.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
index 5e0da5e..d91a3a1 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)
-- 
1.7.0.4




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic