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 <cursoragent@cursor.com>
This commit is contained in:
+8
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user