test(parser): treat reaped container zombies as terminated
This commit is contained in:
@@ -738,6 +738,17 @@ def test_parser_timeout_terminates_descendants(monkeypatch, tmp_path):
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
else:
|
||||
# Minimal CI containers may not run an init process that promptly
|
||||
# reaps orphaned children. A zombie has already been terminated and
|
||||
# cannot execute or retain parser resources, even though kill(pid, 0)
|
||||
# continues to see its process-table entry.
|
||||
stat_path = Path(f"/proc/{descendant_pid}/stat")
|
||||
try:
|
||||
state = stat_path.read_text(encoding="ascii").split()[2]
|
||||
except (FileNotFoundError, IndexError, OSError):
|
||||
state = None
|
||||
if state == "Z":
|
||||
return
|
||||
os.kill(descendant_pid, 9)
|
||||
raise AssertionError("Parser descendant survived the parent deadline")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user