Use SIGKILL and os.getpgid for reliable job killing

SIGTERM was being ignored by child processes. Use SIGKILL via the
actual process group ID, with proc.kill() as fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 18:16:09 +02:00
parent 5e21d1b20a
commit 6a0389f437

View File

@@ -82,9 +82,13 @@ class JobManager:
@staticmethod @staticmethod
def _kill_process_group(proc: asyncio.subprocess.Process) -> None: def _kill_process_group(proc: asyncio.subprocess.Process) -> None:
try: try:
os.killpg(proc.pid, signal.SIGTERM) pgid = os.getpgid(proc.pid)
except (ProcessLookupError, PermissionError): os.killpg(pgid, signal.SIGKILL)
pass except (ProcessLookupError, PermissionError, OSError):
try:
proc.kill()
except (ProcessLookupError, OSError):
pass
def kill_job(self, job_id: str) -> bool: def kill_job(self, job_id: str) -> bool:
job = self._jobs.get(job_id) job = self._jobs.get(job_id)