From 7af5f4689f63bc6ffec441178166c562fee28bc6 Mon Sep 17 00:00:00 2001 From: Ryota Ozaki Date: Thu, 22 Jul 2010 18:57:43 +0200 Subject: [PATCH] lxc: force kill of init process by sending SIGKILL if needed Init process may remain after sending SIGTERM for some reason. For example, if original init program is used, it is definitely not killed by SIGTERM. * src/lxc/lxc_controller.c: kill with SIGKILL if SIGTERM wasn't sufficient --- src/lxc/lxc_controller.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 44bcc82015..d8b7bc7bf1 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -663,7 +663,11 @@ cleanup: close(containerPty); if (container > 1) { + int status; kill(container, SIGTERM); + if (!(waitpid(container, &status, WNOHANG) == 0 && + WIFEXITED(status))) + kill(container, SIGKILL); waitpid(container, NULL, 0); } return rc; -- 2.39.5