test(cpg-budget): a process vanishing mid-read is the success case too

Reading /proc/<pid>/stat for a process that is reaped during the read raises
ProcessLookupError (ESRCH), not FileNotFoundError. The previous race fix caught only
the latter, so the hanging-process-group test failed twice today under full-suite
load. It passed alone. The disappearance is exactly what the test asserts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
Marius Ciepluch
2026-09-26 07:44:33 +02:00
co-authored by Claude Opus 5.5
parent 63460f8af4
commit 64ef488ce4
+3 -2
View File
@@ -68,11 +68,12 @@ while True: time.sleep(1)
status = Path(f"/proc/{pid}/stat") status = Path(f"/proc/{pid}/stat")
for _ in range(30): for _ in range(30):
# Read, never check-then-read: a killed process can be reaped between the two, and its # Read, never check-then-read: a killed process can be reaped between the two, and its
# disappearing is exactly the outcome this test wants, not an error. # disappearing is exactly the outcome this test wants, not an error. It can vanish before the
# open (FileNotFoundError) or during the read, which the kernel reports as ESRCH.
try: try:
if status.read_text().split()[2] == "Z": if status.read_text().split()[2] == "Z":
break break
except FileNotFoundError: except (FileNotFoundError, ProcessLookupError):
break break
time.sleep(0.005) time.sleep(0.005)
else: else: