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)