fix: broaden _mine_already_running catch — Windows os.kill raises plain OSError

On Windows, os.kill(bogus_pid, 0) raises OSError[WinError 87]
"The parameter is incorrect" — NOT ProcessLookupError. The old
except tuple missed it, so test_mine_already_running_dead_pid
failed on Windows CI.

Catching OSError covers ProcessLookupError + PermissionError +
FileNotFoundError on POSIX and WinError 87 on Windows. ValueError
still guards the int() parse.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
jp
2026-04-18 21:13:37 -07:00
parent a6b6e55247
commit fe6b8899bc
+4 -1
View File
@@ -159,7 +159,10 @@ def _mine_already_running() -> bool:
pid = int(_MINE_PID_FILE.read_text().strip())
os.kill(pid, 0) # signal 0 = existence check, no actual signal sent
return True
except (FileNotFoundError, ValueError, ProcessLookupError, PermissionError):
except (OSError, ValueError):
# OSError covers: FileNotFoundError (no pid file), ProcessLookupError
# (dead PID on POSIX), PermissionError (not our process), and
# WinError 87 / "invalid parameter" (dead or unknown PID on Windows).
return False