From 97419ba733136ae55695d86b39ef4a7d89107c16 Mon Sep 17 00:00:00 2001 From: Meliox Date: Tue, 18 Aug 2026 19:12:22 +0200 Subject: [PATCH] fix --- src/modules/node_info/files/ProcessManager.pm | 9 ++++++++- src/modules/node_info/files/Utils.pm | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/node_info/files/ProcessManager.pm b/src/modules/node_info/files/ProcessManager.pm index 741717f..c375941 100644 --- a/src/modules/node_info/files/ProcessManager.pm +++ b/src/modules/node_info/files/ProcessManager.pm @@ -112,7 +112,14 @@ sub notify_pve_mod_worker { # ============================================================================ sub _worker_lock_file_exists { - return -f $pve_mod_worker_lock; + return 0 unless -f $pve_mod_worker_lock; + my $pid = read_lock_pid($pve_mod_worker_lock); + if (defined $pid && $pid =~ /^(\d+)$/ && is_process_alive($1)) { + return 1; + } + debug(__LINE__, "Stale or zombie worker lock found, removing it"); + unlink($pve_mod_worker_lock); + return 0; } # Forks the worker process and records its PID in the lock file. diff --git a/src/modules/node_info/files/Utils.pm b/src/modules/node_info/files/Utils.pm index 2dcc765..48deeb1 100644 --- a/src/modules/node_info/files/Utils.pm +++ b/src/modules/node_info/files/Utils.pm @@ -91,7 +91,15 @@ sub read_sysfs { sub is_process_alive { my ($pid) = @_; - return -d "/proc/$pid"; + return 0 unless -d "/proc/$pid"; + # A zombie still has /proc/ but is dead - otherwise a stale + # worker lock is never cleaned up. + if (open my $fh, '<', "/proc/$pid/stat") { + my $line = <$fh>; + close $fh; + return 0 if defined $line && $line =~ /\)\s+Z\s/; + } + return 1; } sub read_lock_pid {