[libvirt] [PATCH] lxc: use common code for process cleanup
Daniel P. Berrange
berrange at redhat.com
Thu Nov 3 14:48:52 UTC 2011
On Thu, Nov 03, 2011 at 08:45:45AM -0600, Eric Blake wrote:
> 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.
> ---
>
> Daniel previously said to wait until after the lxc multi-console
> patches were in before visiting this file; but now that those are
> in, this fix is still applicable:
> https://www.redhat.com/archives/libvir-list/2011-October/msg01083.html
>
> src/lxc/lxc_controller.c | 11 +++--------
> 1 files changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index 649ac87..137ef52 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;
> }
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list