Skip to content

fix(util): IsProcessAlive treats zombies as dead on Linux (#1839) - #1976

Merged
topcheer merged 1 commit into
mainfrom
fix-1839
Sep 9, 2026
Merged

fix(util): IsProcessAlive treats zombies as dead on Linux (#1839)#1976
topcheer merged 1 commit into
mainfrom
fix-1839

Conversation

@topcheer

@topcheer topcheer commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #1839 (case 1; the remaining findings were falsified/adjudicated in the issue).

  • Case 1 (Low-Med): kill(pid,0) succeeds for zombies — IsProcessAlive kept crash-recovery anchors and IM instance files stale. Linux: /proc//stat state check (Z/X/x → dead), LAST-')' parse for safe comm fields; /proc-less platforms keep the conservative signal-0 verdict (documented); Windows untouched (helper already handles exit state).

Verification evidence (review)

Isolated worktree: util suite PASS (p=1) + GOOS=windows build OK. Pin: real-child zombie (polls to Z state; skips on /proc-less hosts — runs for real on Linux CI) + verdicts-unchanged for live/dead.

Closes #1839

Generated with ggcode

kill(pid, 0) succeeds for a zombie (exited but unreaped), so
IsProcessAlive reported dead instances as alive - crash-recovery
anchors (run_journal) and IM instance detection kept stale state
instead of cleaning it up. The issue rated this Low-Med: the error
direction is fail-safe (residue over wrongful deletion) and needs a
hung-parent window.

On Linux, signal-0 success is now followed by a /proc/<pid>/stat
state check: Z/X/x states are reported dead. Platforms without /proc
(e.g. macOS) keep the signal-0-only verdict - documented, conservative.
Parse uses the LAST ')' so comm fields containing spaces/parens stay
safe. Windows is untouched (its helper already handles exit state).

Pin: zombie-not-alive (real child + poll to Z state; skips on
/proc-less hosts) + verdicts-unchanged for live/dead.

util suite PASS (p=1); GOOS=windows build OK.

Closes #1839

Co-Authored-By: ggcode <noreply@ggcode.dev>

@topcheer topcheer left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

验证证据(隔离 worktree):util 全套 PASS(-p=1)+GOOS=windows 交叉 OK。钉扎真实子进程轮询至 Z 态(macOS 无 /proc 按设计跳过——Linux CI 实跑)+live/dead 判定不变守卫。

@topcheer
topcheer merged commit d160273 into main Sep 9, 2026
9 checks passed
@topcheer
topcheer deleted the fix-1839 branch September 9, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment