Add debug output to kill_job to diagnose kill failure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 18:20:53 +02:00
parent 0110b00b67
commit 54c7b75cee
2 changed files with 19 additions and 9 deletions

View File

@@ -93,12 +93,24 @@ class JobManager:
except (ProcessLookupError, OSError):
pass
def kill_job(self, job_id: str) -> bool:
def kill_job(self, job_id: str) -> str:
"""Kill a job. Returns a status message for debugging."""
job = self._jobs.get(job_id)
if not job or job._proc is None:
return False
self._kill_process_group(job._proc)
return True
if not job:
return "job not found"
if job._proc is None:
return f"proc is None (status={job.status})"
pid = job._proc.pid
try:
pgid = os.getpgid(pid)
os.killpg(pgid, signal.SIGKILL)
return f"killed pgid={pgid} (pid={pid})"
except (ProcessLookupError, PermissionError, OSError) as e:
try:
job._proc.kill()
return f"fallback kill pid={pid} ({e})"
except (ProcessLookupError, OSError) as e2:
return f"failed: {e}, {e2}"
def kill_running(self) -> None:
for job in self._jobs.values():

View File

@@ -104,10 +104,8 @@ class RunningTasksScreen(Screen):
)
def _do_kill(self, job_id: str) -> None:
if job_manager.kill_job(job_id):
self.notify("Job killed")
else:
self.notify("Could not kill job", severity="error")
result = job_manager.kill_job(job_id)
self.notify(f"Kill: {result}")
def action_go_back(self) -> None:
self.app.pop_screen()