From 8aee48bdaafd2ffe4978652de8c9d8d5f56c5d58 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 21 Oct 2011 11:09:23 -0600 Subject: [PATCH] lxc: use common code for process cleanup 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 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 649ac87bb4..137ef52860 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -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; }