[libvirt] [PATCH] lxc: Ensure to kill 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 | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 44bcc82..d8b7bc7 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; -- 1.6.6.1

ping? Note that this patch would fix https://bugzilla.redhat.com/show_bug.cgi?id=592170 . Thanks, ozaki-r On Sat, Jul 17, 2010 at 1:13 AM, Ryota Ozaki <ozaki.ryota@gmail.com> wrote:
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 | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 44bcc82..d8b7bc7 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; -- 1.6.6.1

On Sat, Jul 17, 2010 at 01:13:32AM +0900, Ryota Ozaki wrote:
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 | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 44bcc82..d8b7bc7 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;
Sounds right, and code looks fine, applied and pushed, thanks! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (2)
-
Daniel Veillard
-
Ryota Ozaki