Skip to content

The agent that grows with you

test(cron): a child mid-reap is exited, not a survivor of cancel

Tekniuma583989f7658
diff --git a/tests/cron/test_cron_script.py b/tests/cron/test_cron_script.py
index 4c1c3dbf5a3..ea64b008215 100644
--- a/tests/cron/test_cron_script.py
+++ b/tests/cron/test_cron_script.py
@@ -778,7 +778,9 @@ class TestScriptTimeoutTreeKill:
def is_live(pid):
try:
process = psutil.Process(pid)
- return process.is_running() and process.status() != psutil.STATUS_ZOMBIE
+ # 'dead' = mid-reap (exited); see test_script_termination_reaps_descendants.
+ return process.is_running() and process.status() not in (
+ psutil.STATUS_ZOMBIE, psutil.STATUS_DEAD)
except (psutil.NoSuchProcess, psutil.ZombieProcess):
return False
diff --git a/tests/cron/test_script_claim_heartbeat.py b/tests/cron/test_script_claim_heartbeat.py
index a727bd5273d..713fbdda09b 100644
--- a/tests/cron/test_script_claim_heartbeat.py
+++ b/tests/cron/test_script_claim_heartbeat.py
@@ -40,8 +40,10 @@ def test_script_termination_reaps_descendants(tmp_path, monkeypatch, trigger, to
except BaseException as exc:
errors.append(exc)
def live(pid):
+ # 'dead' is the instant a parent is reaping the zombie: exited, not alive. Counting it
+ # alive flips a gone child back to "survived" on the read after the loop saw a zombie.
try:
- return psutil.Process(pid).status() != psutil.STATUS_ZOMBIE
+ return psutil.Process(pid).status() not in (psutil.STATUS_ZOMBIE, psutil.STATUS_DEAD)
except psutil.NoSuchProcess:
return False
thread = threading.Thread(target=run)
diff --git a/tests/tools/test_mcp_stability.py b/tests/tools/test_mcp_stability.py
index 946c90dab74..eb7027c16a4 100644
--- a/tests/tools/test_mcp_stability.py
+++ b/tests/tools/test_mcp_stability.py
@@ -492,7 +492,9 @@ class TestStdioPgroupReaping:
deadline = _time.time() + 10
def _alive() -> bool:
try:
- return psutil.Process(grandchild_pid).status() != psutil.STATUS_ZOMBIE
+ # 'dead' = mid-reap (exited), not a survivor.
+ return psutil.Process(grandchild_pid).status() not in (
+ psutil.STATUS_ZOMBIE, psutil.STATUS_DEAD)
except psutil.NoSuchProcess:
return False
while _time.time() < deadline and _alive():