fix(file-ops): reuse _kill_process_group_posix in the native rg runner

A bare os.killpg/signal.SIGKILL trips the Windows-footgun lane (the module is
imported on Windows even though the native lane never runs there). The local
environment already has the POSIX group killer with the TERM→KILL escalation
and setsid-escapee sweep; use it.
This commit is contained in:
kshitijk4poor
2026-09-07 00:22:40 +05:30
committed by kshitij
parent 9158bd8e0d
commit 2d77992750

View File

@@ -4,12 +4,10 @@
(no I/O).
"""
import contextlib
import os
import posixpath
import re
import shlex
import signal
import subprocess
import sys
import threading
@@ -335,7 +333,7 @@ class SearchMixin:
``merge_stderr`` mirrors the shell path's stderr handling: merged for content
search (diagnostics feed the error message), discarded (``2>/dev/null``) for
file lists and probes."""
from tools.environments.local import _make_run_env
from tools.environments.local import _kill_process_group_posix, _make_run_env
cwd = getattr(self.env, "cwd", None) or self.cwd
args = shlex.split(" ".join(argv))
try:
@@ -373,8 +371,7 @@ class SearchMixin:
exit_code = 124
break
if proc.poll() is None:
with contextlib.suppress(ProcessLookupError, PermissionError):
os.killpg(proc.pid, signal.SIGKILL)
_kill_process_group_posix(proc) # native lane is POSIX-only (gate above)
proc.wait()
drainer.join()
proc.stdout.close()