mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 06:50:22 +03:00
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.
This commit is contained in:
parent
209c2880b9
commit
8aee48bdaa
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user