test(scripts): treat a process that exits mid-read as gone
Reading /proc/<pid>/stat raises ProcessLookupError when the process exits between the open and the read, which made the lane-kill tests fail now and then. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
4f0b8e0cfe
commit
3726b5c53f
1 file changed
+1
-1
@@ -353,7 +353,7 @@ def alive(pid):
|
||||
"""Whether pid is a running process, not gone or a zombie."""
|
||||
try:
|
||||
stat = pathlib.Path(f"/proc/{pid}/stat").read_text()
|
||||
except FileNotFoundError:
|
||||
except (FileNotFoundError, ProcessLookupError): # gone before or during the read
|
||||
return False
|
||||
return stat.rsplit(")", 1)[1].split()[0] != "Z"
|
||||
|
||||
|
||||
Reference in new issue
Block a user