fix(cli): keep child cleanup working on Windows

_cleanup_children() called os.killpg unconditionally — Windows doesn't
have killpg as an attribute on os, so the call raised AttributeError
(not caught by the existing OSError-family handler) and aborted cleanup.
Guard with hasattr(os, "killpg") and fall back to os.kill(pid, SIGTERM)
on platforms without process-group APIs. Closes #226. Refs #110.

Co-authored-by: gujishh <baiaoshh@163.com>
This commit is contained in:
Trevin Chow
2026-05-17 01:28:55 -07:00
parent 5994b4f76a
commit 16ce073d0c
+4 -1
View File
@@ -63,7 +63,10 @@ def _cleanup_children() -> None:
pids = list(_child_pids) pids = list(_child_pids)
for pid in pids: for pid in pids:
try: try:
os.killpg(os.getpgid(pid), signal.SIGTERM) if hasattr(os, "killpg"):
os.killpg(os.getpgid(pid), signal.SIGTERM)
else:
os.kill(pid, signal.SIGTERM)
except (ProcessLookupError, PermissionError, OSError): except (ProcessLookupError, PermissionError, OSError):
continue continue