fix #6073: esxi: fix zombie process after storage removal
After removing an ESXi storage, a zombie process is generated because the forked FUSE process (esxi-folder-fuse) is not properly reaped. This patch implements a double-fork mechanism to ensure the FUSE process is reparented to init (PID 1), which will properly reap it when it exits. Additionally adds the missing waitpid() call to reap the intermediate child process. Tested on Proxmox VE 8.4.1 with ESXi 8.0U3e storage. Signed-off-by: Stelios Vailakakis <stelios@libvirt.dev> Link: https://lore.proxmox.com/20250701154135.2387872-1-stelios@libvirt.dev
This commit is contained in:
committed by
Thomas Lamprecht
parent
609752f3ae
commit
c33abdf062
@ -211,7 +211,17 @@ sub esxi_mount : prototype($$$;$) {
|
||||
if (!$pid) {
|
||||
eval {
|
||||
undef $rd;
|
||||
POSIX::setsid();
|
||||
|
||||
# Double fork to properly daemonize
|
||||
POSIX::setsid() or die "failed to create new session: $!\n";
|
||||
my $pid2 = fork();
|
||||
die "second fork failed: $!\n" if !defined($pid2);
|
||||
|
||||
if ($pid2) {
|
||||
# First child exits immediately
|
||||
POSIX::_exit(0);
|
||||
}
|
||||
# Second child (grandchild) enters systemd scope
|
||||
PVE::Systemd::enter_systemd_scope(
|
||||
$scope_name_base,
|
||||
"Proxmox VE FUSE mount for ESXi storage $storeid (server $host)",
|
||||
@ -243,6 +253,8 @@ sub esxi_mount : prototype($$$;$) {
|
||||
}
|
||||
POSIX::_exit(1);
|
||||
}
|
||||
# Parent wait for first child to exit
|
||||
waitpid($pid, 0);
|
||||
undef $wr;
|
||||
|
||||
my $result = do { local $/ = undef; <$rd> };
|
||||
|
||||
Reference in New Issue
Block a user