]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc: use common code for process cleanup
authorEric Blake <eblake@redhat.com>
Fri, 21 Oct 2011 17:09:23 +0000 (11:09 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 3 Nov 2011 14:44:19 +0000 (08:44 -0600)
Based on a Coverity report - the return value of waitpid() should
always be checked, to avoid problems with leaking resources.

* src/lxc/lxc_controller.c (lxcControllerRun): Use simpler virPidAbort.

src/lxc/lxc_controller.c

index 649ac87bb43961897865265128fccd42ac3e8a5c..137ef528609dc4ca9716dc7d5d9400f4ab03bda6 100644 (file)
@@ -59,6 +59,7 @@
 #include "util.h"
 #include "virfile.h"
 #include "virpidfile.h"
+#include "command.h"
 
 #define VIR_FROM_THIS VIR_FROM_LXC
 
@@ -1266,14 +1267,8 @@ cleanup:
         VIR_FORCE_CLOSE(loopDevs[i]);
     VIR_FREE(loopDevs);
 
-    if (container > 1) {
-        int status;
-        kill(container, SIGTERM);
-        if (!(waitpid(container, &status, WNOHANG) == 0 &&
-            WIFEXITED(status)))
-            kill(container, SIGKILL);
-        waitpid(container, NULL, 0);
-    }
+    virPidAbort(container);
+
     return rc;
 }