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:
@@ -159,7 +159,10 @@ def _mine_already_running() -> bool:
|
|||||||
pid = int(_MINE_PID_FILE.read_text().strip())
|
pid = int(_MINE_PID_FILE.read_text().strip())
|
||||||
os.kill(pid, 0) # signal 0 = existence check, no actual signal sent
|
os.kill(pid, 0) # signal 0 = existence check, no actual signal sent
|
||||||
return True
|
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
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user