Kill in-flight tools instantly on quit via killpg(self)

When eris quits, _python_exit joins executor threads, which block on
in-flight subprocess.run calls for up to TIMEOUT seconds. After saving
state, kill the process group to reap all tool subprocesses instantly.
Isolate editor/xdg-open in their own sessions so they survive.
This commit is contained in:
Andrew Hamilton 2026-08-03 10:27:38 +10:00
parent eebb226b21
commit 87813fdf21

View file

@ -791,7 +791,8 @@ class Screen:
self._log.log_message([in_green("Editing "), path_colored,
in_green(f" at line {line_num}…")])
subprocess.Popen(f"{self.editor_command} +{line_num} {path}", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
start_new_session=True)
def patch_file(self):
result = self._summary.get_selection()
if hasattr(result.tool, "patch_command") and result.tool.patch_command is not None:
@ -849,7 +850,8 @@ class Screen:
path = self._summary.get_selection().path
path_colored = lscolors.path_colored(path)
self._log.log_message([in_green("Opening "), path_colored, in_green("…")])
subprocess.Popen(["xdg-open", path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocess.Popen(["xdg-open", path], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
start_new_session=True)
def save(self):
worker.Worker.unsaved_jobs_total = 0
@ -1077,6 +1079,8 @@ async def main(title, root_path, worker_count=None, editor_command=None, theme=N
notifier.stop()
if summary.is_loaded:
screen.save()
if sys.stdout.isatty() and os.getpgrp() == os.getpid():
os.killpg(os.getpgrp(), signal.SIGKILL)
@contextlib.contextmanager