[PATCH] lxc: Ensure to kill init process by sending SIGKILL if needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]