This avoids accidentally killing a potentially completely unrelated
process that was spawned in an edge case between the last check in the
timeout loop and the kill command.

Signed-off-by: Daniel Tschlatscher <d.tschlatsc...@proxmox.com>
---
Changes from v3:
* New patch

 PVE/QemuServer.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 549d666..e14b76e 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6241,7 +6241,7 @@ sub _do_vm_stop {
 
     if ($count >= $timeout) {
        warn "VM still running - terminating now with SIGKILL\n";
-       kill 9, $pid;
+       kill(9, $pid) if check_running($vmid, $nocheck) eq $pid;
        sleep 1;
     }
 
-- 
2.30.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to