From 20a47331526bbd753a36124c120405d4fa3bc422 Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 12 Oct 2026 09:35:27 +0000 Subject: [PATCH] Treat zombie PIDs as dead in batch update regression Why: CI containers leave unreaped zombies; os.kill(0) still succeeds and falsely failed the old-process-stopped assertion. Evidence: local unittest of the batch update case. Impact: assertion matches svc.sh/recover zombie semantics. Refs: .task/feature-svc-pidcheck-leak.md; PR #457 Co-authored-by: Cursor --- tests/test_svc.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_svc.py b/tests/test_svc.py index ba267b72..87767787 100644 --- a/tests/test_svc.py +++ b/tests/test_svc.py @@ -634,9 +634,16 @@ class SvcDbRecoveryTests(unittest.TestCase): new_pid = int((self.runtime(name) / "svc.pid").read_text().strip()) self.assertNotEqual(new_pid, old_pids[name], "%s 应已换新进程" % name) + # 与 svc.sh / recover 夹具一致:僵尸按死处理(CI 容器 PID 1 不收割)。 + old_still = False try: os.kill(old_pids[name], 0) - old_still = True + try: + state = Path("/proc/%d/stat" % old_pids[name]).read_text() \ + .rsplit(")", 1)[1].split()[0] + old_still = state != "Z" + except (OSError, IndexError): + old_still = True except (ProcessLookupError, PermissionError): old_still = False self.assertFalse(old_still, "%s 旧进程应已停止" % name)