From be90c8d2d315391b69a5ea965335174e205385b5 Mon Sep 17 00:00:00 2001 From: nianyucatfish <156216359+nianyucatfish@users.noreply.github.com> Date: Fri, 10 Jul 2026 22:25:54 +0800 Subject: [PATCH] fix(tui-v2): detach tool subprocess stdin (#678) --- frontends/tuiapp_v2.py | 5 +++-- ga.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontends/tuiapp_v2.py b/frontends/tuiapp_v2.py index ca08a58c..5d61c071 100644 --- a/frontends/tuiapp_v2.py +++ b/frontends/tuiapp_v2.py @@ -1469,7 +1469,8 @@ _HAS_WAYLAND = bool(os.environ.get("WAYLAND_DISPLAY")) def _clipboard_run(cmd: list[str], input: bytes | None = None, timeout: float = 3.0) -> bytes | None: try: - r = subprocess.run(cmd, input=input, capture_output=True, timeout=timeout) + stdin = subprocess.DEVNULL if input is None else None + r = subprocess.run(cmd, input=input, stdin=stdin, capture_output=True, timeout=timeout) return r.stdout if r.returncode == 0 else None except (FileNotFoundError, subprocess.TimeoutExpired, OSError): return None @@ -6365,7 +6366,7 @@ class GenericAgentTUI(App[None]): out = ''; rc = 0 try: r = subprocess.run( - shell_argv + [cmd], capture_output=True, + shell_argv + [cmd], stdin=subprocess.DEVNULL, capture_output=True, timeout=30, encoding='utf-8', errors='replace', ) out = (r.stdout or '') + (r.stderr or '') diff --git a/ga.py b/ga.py index c6d4ccfd..9b23e217 100644 --- a/ga.py +++ b/ga.py @@ -56,7 +56,8 @@ def code_run(code, code_type="python", timeout=60, cwd=None, code_cwd=None, stop try: process = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + cmd, stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0, cwd=cwd, startupinfo=startupinfo, creationflags=0x08000000 if os.name == 'nt' else 0 )