From fe6b8899bc29dcb40a919b7bb45916a44bd83bd5 Mon Sep 17 00:00:00 2001 From: jp Date: Sat, 18 Apr 2026 21:13:37 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20broaden=20=5Fmine=5Falready=5Frunning=20?= =?UTF-8?q?catch=20=E2=80=94=20Windows=20os.kill=20raises=20plain=20OSErro?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- mempalace/hooks_cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mempalace/hooks_cli.py b/mempalace/hooks_cli.py index f325d80..ce73fbf 100644 --- a/mempalace/hooks_cli.py +++ b/mempalace/hooks_cli.py @@ -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