This commit is contained in:
Meliox 2026-08-18 19:12:22 +02:00
parent e46734cd37
commit 97419ba733
2 changed files with 17 additions and 2 deletions

View File

@ -112,7 +112,14 @@ sub notify_pve_mod_worker {
# ============================================================================ # ============================================================================
sub _worker_lock_file_exists { 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. # Forks the worker process and records its PID in the lock file.

View File

@ -91,7 +91,15 @@ sub read_sysfs {
sub is_process_alive { sub is_process_alive {
my ($pid) = @_; my ($pid) = @_;
return -d "/proc/$pid"; return 0 unless -d "/proc/$pid";
# A zombie still has /proc/<pid> 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 { sub read_lock_pid {