]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: force kill of init process by sending SIGKILL if needed
authorRyota Ozaki <ozaki.ryota@gmail.com>
Thu, 22 Jul 2010 16:57:43 +0000 (18:57 +0200)
committerDaniel Veillard <veillard@redhat.com>
Thu, 22 Jul 2010 16:57:43 +0000 (18:57 +0200)
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

index 44bcc82015c81f4a48e2ce5219320bf01617d4cd..d8b7bc7bf10fafc6900403458dba53c22b8c0d36 100644 (file)
@@ -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;