Skip to content

Commit 8a2a75b

Browse files
committed
fix: only treat process-group survivors as healthy when the zombie is the group leader
1 parent dc640b4 commit 8a2a75b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/status/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,13 +2076,21 @@ impl StatusManager {
20762076
/// other than the recorded PID itself. A wrapper shell can exit while the real worker keeps
20772077
/// running (reparented to PID 1 but retaining the original group); in that case the recorded
20782078
/// PID reads as a zombie even though the service is genuinely healthy.
2079+
///
2080+
/// This only applies when the recorded PID is its own process-group leader (`pid == pgid`),
2081+
/// which systemg guarantees for service wrappers via `setpgid(0, 0)`. A bare process that
2082+
/// merely inherited an unrelated group (e.g. the supervisor's own) is a genuine zombie.
20792083
#[cfg(target_os = "linux")]
20802084
fn process_group_has_live_member(pid: u32) -> bool {
20812085
let Ok(pgid) = getpgid(Some(Pid::from_raw(pid as i32))) else {
20822086
return false;
20832087
};
20842088
let pgid = pgid.as_raw();
20852089

2090+
if pgid != pid as i32 {
2091+
return false;
2092+
}
2093+
20862094
let Ok(entries) = fs::read_dir("/proc") else {
20872095
return false;
20882096
};

0 commit comments

Comments
 (0)