Skip to content

Commit d4fcdb0

Browse files
georgeh0claude
andcommitted
fix: catch SystemError from os.kill on Windows
On Windows, os.kill(pid, 0) raises SystemError when the target process has exited but its handle state is in transition (WinError 87). This corrupts CPython C exception state, causing subsequent built-in calls like time.monotonic() to also raise SystemError. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c16a364 commit d4fcdb0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/cocoindex_code/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,11 @@ def _pid_alive(pid: int) -> bool:
227227
return False
228228
except PermissionError:
229229
return True # process exists but we can't signal it
230-
except OSError:
231-
return False # assume dead on unexpected OS errors (e.g. Windows edge cases)
230+
except (OSError, SystemError):
231+
# On Windows, os.kill(pid, 0) can raise SystemError or unexpected OSError
232+
# variants (e.g. WinError 87 "The parameter is incorrect") for PIDs that
233+
# have exited but whose handles haven't been fully released.
234+
return False
232235

233236

234237
def stop_daemon() -> None:

0 commit comments

Comments
 (0)