The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(lint): stdin guard catches calls whose arguments start on the next line (review)
alt-glitch1b8bd66b7f9f
diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.pyindex be021eb4f8e..a6148e0e7fd 100644--- a/agent/anthropic_adapter.py+++ b/agent/anthropic_adapter.py@@ -287,7 +287,7 @@ def _detect_claude_code_version() -> str:with suppress(Exception):result = subprocess.run([cmd, "--version"],- capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=5,+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=5,)if result.returncode == 0 and result.stdout.strip():version = result.stdout.strip().split()[0] # "2.1.74 (Claude Code)" or "2.1.74"diff --git a/agent/command_token_source.py b/agent/command_token_source.pyindex 08c6d047630..fdcf2e7f343 100644--- a/agent/command_token_source.py+++ b/agent/command_token_source.py@@ -51,7 +51,7 @@ def _mint(command: str, label: str) -> tuple[str, Optional[float]]:try:completed = subprocess.run(- command, shell=True, capture_output=True, text=True, errors="replace", timeout=_MINT_TIMEOUT_SECONDS,+ command, stdin=subprocess.DEVNULL, shell=True, capture_output=True, text=True, errors="replace", timeout=_MINT_TIMEOUT_SECONDS,env=served_profile_child_env(inherit_credentials=True),)except subprocess.TimeoutExpired as exc:diff --git a/agent/deadline.py b/agent/deadline.pyindex 6e568d8932e..5dd11172f28 100644--- a/agent/deadline.py+++ b/agent/deadline.py@@ -431,7 +431,7 @@ def kill_process_tree(pid: int, *, sig: Optional[int] = None) -> bool:try:proc = subprocess.run(["taskkill", "/F", "/T", "/PID", str(pid)],- capture_output=True, timeout=15, check=False, creationflags=creationflags,+ stdin=subprocess.DEVNULL, capture_output=True, timeout=15, check=False, creationflags=creationflags,)# taskkill exits non-zero for not-found / access-denied (False = nothing terminated).return proc.returncode == 0diff --git a/optional-skills/creative/ai-presenter-video/scripts/preflight.py b/optional-skills/creative/ai-presenter-video/scripts/preflight.pyindex ef4905be31a..2bd757cd3b0 100755--- a/optional-skills/creative/ai-presenter-video/scripts/preflight.py+++ b/optional-skills/creative/ai-presenter-video/scripts/preflight.py@@ -23,7 +23,7 @@ def probe(path: Path) -> dict[str, Any]:"json",str(path),],- check=True,+ stdin=subprocess.DEVNULL, check=True,capture_output=True,text=True,)diff --git a/optional-skills/creative/comfyui/scripts/hardware_check.py b/optional-skills/creative/comfyui/scripts/hardware_check.pyindex feb7cfab91f..5699c9933ba 100755--- a/optional-skills/creative/comfyui/scripts/hardware_check.py+++ b/optional-skills/creative/comfyui/scripts/hardware_check.py@@ -54,7 +54,7 @@ _COMFY_CLI_FLAG = {def _run(cmd: list[str], timeout: int = 8) -> str:try:out = subprocess.run(- cmd, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=timeout, check=False+ cmd, stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=timeout, check=False)return (out.stdout or "") + (out.stderr or "")except (FileNotFoundError, subprocess.TimeoutExpired, OSError):diff --git a/optional-skills/creative/kanban-video-orchestrator/scripts/monitor.py b/optional-skills/creative/kanban-video-orchestrator/scripts/monitor.pyindex dc3c11845b7..7e27e21bd0a 100755--- a/optional-skills/creative/kanban-video-orchestrator/scripts/monitor.py+++ b/optional-skills/creative/kanban-video-orchestrator/scripts/monitor.py@@ -36,7 +36,7 @@ def kanban_list(tenant: str) -> list[dict]:try:out = subprocess.run(["hermes", "kanban", "list", "--tenant", tenant, "--json"],- capture_output=True, text=True, encoding='utf-8', errors='replace', check=False,+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', check=False,)if out.returncode == 0 and out.stdout.strip().startswith("["):return json.loads(out.stdout)@@ -45,7 +45,7 @@ def kanban_list(tenant: str) -> list[dict]:# Fallback: textual parse of `hermes kanban list`out = subprocess.run(["hermes", "kanban", "list", "--tenant", tenant],- capture_output=True, text=True, encoding='utf-8', errors='replace', check=False,+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', check=False,)rows = []for line in out.stdout.splitlines():@@ -69,7 +69,7 @@ def kanban_list(tenant: str) -> list[dict]:def kanban_show(task_id: str) -> dict | None:out = subprocess.run(["hermes", "kanban", "show", task_id, "--json"],- capture_output=True, text=True, encoding='utf-8', errors='replace', check=False,+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', check=False,)if out.returncode != 0:return Nonediff --git a/optional-skills/creative/pixel-art/scripts/pixel_art_video.py b/optional-skills/creative/pixel-art/scripts/pixel_art_video.pyindex 3b584144d9a..ac5c66bd185 100644--- a/optional-skills/creative/pixel-art/scripts/pixel_art_video.py+++ b/optional-skills/creative/pixel-art/scripts/pixel_art_video.py@@ -300,7 +300,7 @@ def pixel_art_video("-i", os.path.join(frames_dir, "frame_%04d.png"),"-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "18",output_path],- check=True,+ stdin=subprocess.DEVNULL, check=True,)gif_path = None@@ -314,7 +314,7 @@ def pixel_art_video("scale=320:-1:flags=neighbor,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse","-loop", "0",gif_path],- check=True,+ stdin=subprocess.DEVNULL, check=True,)return output_path, gif_pathdiff --git a/optional-skills/finance/excel-author/scripts/recalc.py b/optional-skills/finance/excel-author/scripts/recalc.pyindex a329dbe7246..743e1216ac8 100644--- a/optional-skills/finance/excel-author/scripts/recalc.py+++ b/optional-skills/finance/excel-author/scripts/recalc.py@@ -53,7 +53,7 @@ def recalc(xlsx_path: str, timeout: int = 60) -> dict:"--outdir",td,],- check=True,+ stdin=subprocess.DEVNULL, check=True,capture_output=True,timeout=timeout,)diff --git a/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py b/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.pyindex 9d062328df3..c170956d2c4 100755--- a/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py+++ b/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py@@ -176,7 +176,7 @@ def which_binary() -> Optional[Path]:try:out = subprocess.run([str(p), "--version"],- capture_output=True,+ stdin=subprocess.DEVNULL, capture_output=True,text=True,timeout=5,)@@ -393,7 +393,7 @@ def run_sg(try:return subprocess.run(cmd,- capture_output=capture,+ stdin=subprocess.DEVNULL, capture_output=capture,text=True,timeout=timeout,)diff --git a/plugins/platforms/photon/adapter.py b/plugins/platforms/photon/adapter.pyindex eceb7bd5d6e..5f8ada9998c 100644--- a/plugins/platforms/photon/adapter.py+++ b/plugins/platforms/photon/adapter.py@@ -294,7 +294,7 @@ def _reinstall_sidecar_deps() -> None:def _run(verb: str) -> subprocess.CompletedProcess:return subprocess.run( # noqa: S603- [npm, verb], cwd=str(_sidecar_dir()), capture_output=True, text=True, encoding="utf-8",+ [npm, verb], stdin=subprocess.DEVNULL, cwd=str(_sidecar_dir()), capture_output=True, text=True, encoding="utf-8",errors="replace", check=False, env=env, timeout=_NPM_REINSTALL_TIMEOUT, creationflags=windows_hide_flags())try:result = _run("ci")@@ -880,7 +880,7 @@ class PhotonAdapter(BasePlatformAdapter):"""stdout of a short shell-out, or None if it failed to run."""try:return subprocess.run( # noqa: S603, S607- cmd, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=5.0,+ cmd, stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=5.0,check=False).stdoutexcept (OSError, subprocess.TimeoutExpired):return Nonediff --git a/plugins/platforms/photon/cli.py b/plugins/platforms/photon/cli.pyindex ec464befcf5..e4328b0df31 100644--- a/plugins/platforms/photon/cli.py+++ b/plugins/platforms/photon/cli.py@@ -314,7 +314,7 @@ def _install_sidecar() -> int:# stdout streams to the terminal; stderr is captured so the failure reason can be# persisted for check_requirements() to surface later.proc = subprocess.run( # noqa: S603- [npm, verb], cwd=str(_sidecar_dir()), check=False, stderr=subprocess.PIPE, text=True, env=env)+ [npm, verb], stdin=subprocess.DEVNULL, cwd=str(_sidecar_dir()), check=False, stderr=subprocess.PIPE, text=True, env=env)if proc.stderr:print(proc.stderr, end="", file=sys.stderr)return procdiff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.pyindex 5850c2083ad..af5b60cff6d 100644--- a/plugins/platforms/telegram/adapter.py+++ b/plugins/platforms/telegram/adapter.py@@ -248,7 +248,7 @@ def _probe_voice_duration_seconds(path: str) -> Optional[int]:if shutil.which("ffprobe"):proc = subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", path],- capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=5)+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=5)if proc.returncode == 0:return _coerce_duration_seconds(proc.stdout.strip())except Exception:@@ -272,7 +272,7 @@ def _probe_video_geometry(path: str) -> Dict[str, int]:["ffprobe", "-v", "error", "-select_streams", "v:0","-show_entries", "stream=width,height", "-show_entries", "format=duration","-of", "json", path],- capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=20)+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=20)if proc.returncode != 0:return {}blob = json.loads(proc.stdout or "{}")@@ -308,7 +308,7 @@ def _video_thumbnail_jpeg(path: str, duration: Optional[int]) -> Optional[str]:proc = subprocess.run(["ffmpeg", "-y", "-ss", str(seek), "-i", path, "-frames:v", "1","-vf", "scale=320:-2", "-q:v", "6", out],- capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30)+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30)if proc.returncode != 0 or not os.path.getsize(out):with contextlib.suppress(OSError):os.remove(out)@@ -4934,7 +4934,7 @@ class TelegramAdapter(TelegramHeldInboundMixin, BasePlatformAdapter):# A user script under HERMES_HOME the agent can write: scrubbed like cron and quick-command scripts.from tools.environments.local import build_subprocess_envproc = await asyncio.create_subprocess_exec(- str(script_path), arg, *extra_args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,+ str(script_path), arg, *extra_args, stdin=asyncio.subprocess.DEVNULL, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,env=build_subprocess_env(strip_launch_profile=True))_stdout_bytes, stderr_bytes = await asyncio.wait_for(proc.communicate(), timeout=60)if proc.returncode == 0:diff --git a/plugins/platforms/whatsapp/adapter.py b/plugins/platforms/whatsapp/adapter.pyindex 36e5a5ec3ac..dde7bf10f76 100644--- a/plugins/platforms/whatsapp/adapter.py+++ b/plugins/platforms/whatsapp/adapter.py@@ -189,7 +189,7 @@ def _terminate_bridge_process(proc, *, force: bool = False) -> None:try:result = subprocess.run(["taskkill", "/PID", str(proc.pid), "/T"] + (["/F"] if force else []),- capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=10,+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=10,)except FileNotFoundError:return getattr(proc, action)()@@ -686,7 +686,7 @@ class WhatsAppAdapter(WhatsAppBehaviorMixin, BasePlatformAdapter):raise RuntimeError("Node.js is no longer available; run `hermes pm install`")self._bridge_process = subprocess.Popen([node, str(bridge_path), "--port", str(self._bridge_port), "--session", str(self._session_path),- "--mode", _wenv("WHATSAPP_MODE", "self-chat")], stdout=bridge_log_fh, stderr=bridge_log_fh, env=self._bridge_env(), **windows_detach_popen_kwargs())+ "--mode", _wenv("WHATSAPP_MODE", "self-chat")], stdin=subprocess.DEVNULL, stdout=bridge_log_fh, stderr=bridge_log_fh, env=self._bridge_env(), **windows_detach_popen_kwargs())_write_bridge_pidfile(self._session_path, self._bridge_process.pid, self._bridge_port)if not await self._wait_for_bridge():return Falsediff --git a/plugins/teams_pipeline/pipeline.py b/plugins/teams_pipeline/pipeline.pyindex 0b370a17806..b7d2eac0bee 100644--- a/plugins/teams_pipeline/pipeline.py+++ b/plugins/teams_pipeline/pipeline.py@@ -338,7 +338,7 @@ class TeamsMeetingPipeline:raise TeamsPipelineRetryableError("Recording fallback requires ffmpeg for audio extraction, but ffmpeg was not found.")audio_path = recording_path.with_suffix(".wav")proc = await asyncio.create_subprocess_exec(- ffmpeg, "-y", "-i", str(recording_path), str(audio_path), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)+ ffmpeg, "-y", "-i", str(recording_path), str(audio_path), stdin=asyncio.subprocess.DEVNULL, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)_stdout, stderr = await proc.communicate()if proc.returncode != 0:raise TeamsPipelineRetryableError(f"ffmpeg audio extraction failed: {stderr.decode('utf-8', errors='replace').strip()}")diff --git a/scripts/check_subprocess_stdin.py b/scripts/check_subprocess_stdin.pyindex 0b12b45fe81..34e3f198363 100644--- a/scripts/check_subprocess_stdin.py+++ b/scripts/check_subprocess_stdin.py@@ -26,7 +26,6 @@ from __future__ import annotationsimport astimport os-import reimport sysfrom pathlib import Path@@ -54,14 +53,14 @@ TUI_CONTEXT_DIRS = [# on ``sys.path`` until the repo root is added.# subprocess and os APIs that inherit stdin by default when called without-# an explicit stdin= argument. The original regex only covered run/Popen-# (gap #1 in #67639); call, check_output, check_call, os.system, and-# asyncio.create_subprocess_* all inherit fd 0 equally.-_SUBPROCESS_PATTERNS = [- r"subprocess\.(run|Popen|call|check_output|check_call)\s*\([\"'a-zA-Z_\[\(]",- r"os\.system\s*\([\"'a-zA-Z_\[\(]",- r"asyncio\.create_subprocess_(exec|shell)\s*\([\"'a-zA-Z_\[\(]",-]+# an explicit stdin= argument, keyed by the module name the call is made on.+# Calls are found as ast.Call nodes, so arguments that start on the next line+# are checked too.+_INHERITING_CALLS = {+ "subprocess": {"run", "Popen", "call", "check_output", "check_call"},+ "os": {"system"},+ "asyncio": {"create_subprocess_exec", "create_subprocess_shell"},+}# Files with intentional stdin= override (e.g. input= creates a pipe).# Format: "filepath:line" or just "filepath" to skip the whole file.@@ -82,120 +81,91 @@ EXEMPT_MARKER = "noqa: subprocess-stdin"SKIP_DIRS = {"tests"}-_SPLAT_RE = re.compile(r"\*\*\s*([A-Za-z_][A-Za-z0-9_]*)")---def _splat_carries_stdin(call_text: str, content: str) -> bool:- """True when the call splats ``**name`` / ``**name(...)`` and ``name`` is defined in- the same file (assignment or ``def``) whose OWN expression/body sets ``stdin=``.+def _definition_sets_stdin(tree: ast.AST, name: str) -> bool:+ """True when ``name`` is defined in the file (assignment or ``def``) and that+ definition's OWN expression/body sets ``stdin=``.Shared kwargs helpers (``_RUN_KW = dict(..., stdin=DEVNULL)``, ``def _run_kwargs(): returndict(..., stdin=DEVNULL)``) legitimately carry the guard; we only accept them when thedefinition provably sets stdin= — never on the helper's name alone, and never because anunrelated later call in the file happens to pass ``stdin=``."""- names = set(_SPLAT_RE.findall(call_text))- if not names:- return False- try:- tree = ast.parse(content)- except SyntaxError:- return False- for name in names:- node = None- for n in ast.walk(tree):- if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef)) and n.name == name:- node = n+ node = None+ for n in ast.walk(tree):+ if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef)) and n.name == name:+ node = n+ break+ if isinstance(n, (ast.Assign, ast.AnnAssign)):+ targets = n.targets if isinstance(n, ast.Assign) else [n.target]+ if any(isinstance(t, ast.Name) and t.id == name for t in targets):+ node = n.value if n.value is not None else nbreak- if isinstance(n, (ast.Assign, ast.AnnAssign)):- targets = n.targets if isinstance(n, ast.Assign) else [n.target]- if any(isinstance(t, ast.Name) and t.id == name for t in targets):- node = n.value if n.value is not None else n- break- if node is None:- return False- # stdin appears as a keyword (dict(stdin=...)) or as a dict-literal key ({"stdin": ...})- # somewhere INSIDE this definition — not merely nearby in the file.- has = any(- (isinstance(sub, ast.keyword) and sub.arg == "stdin")- or (isinstance(sub, ast.Constant) and sub.value == "stdin")- for sub in ast.walk(node)- )- if not has:- return False- return True+ return node is not None and _sets_stdin(node)+++def _sets_stdin(node: ast.AST) -> bool:+ """stdin appears as a keyword (dict(stdin=...)) or a dict-literal key ({"stdin": ...})."""+ return any(+ (isinstance(sub, ast.keyword) and sub.arg == "stdin")+ or (isinstance(sub, ast.Constant) and sub.value == "stdin")+ for sub in ast.walk(node)+ )+++def _is_inheriting_call(call: ast.Call) -> bool:+ """``subprocess.run(...)``, ``os.system(...)`` etc., including ``x.subprocess.run(...)``."""+ func = call.func+ if not isinstance(func, ast.Attribute):+ return False+ owner = func.value+ owner_name = owner.id if isinstance(owner, ast.Name) else getattr(owner, "attr", None)+ return func.attr in _INHERITING_CALLS.get(owner_name, ())+++def _call_is_safe(call: ast.Call, tree: ast.AST) -> bool:+ for kw in call.keywords:+ # stdin= set, or input= (creates a pipe).+ if kw.arg in ("stdin", "input"):+ return True+ if kw.arg is not None:+ continue+ # ``**name`` / ``**name(...)`` splat: safe when the same-file definition sets stdin=.+ value = kw.value.func if isinstance(kw.value, ast.Call) else kw.value+ if isinstance(value, ast.Name):+ if _definition_sets_stdin(tree, value.id):+ return True+ elif _sets_stdin(kw.value): # inline ``**dict(stdin=...)`` / ``**{"stdin": ...}``+ return True+ return Falsedef find_subprocess_calls(content: str, filepath: str) -> list[dict]:"""Find all subprocess/os/asyncio calls missing stdin= in content."""- violations = []lines = content.split("\n")+ try:+ tree = ast.parse(content)+ except SyntaxError as exc:+ # Fail closed: an unparsable file cannot be shown to be safe.+ return [{"file": filepath, "line": exc.lineno or 1, "snippet": f"SyntaxError: {exc.msg}"}]- # Match only actual function calls — not comments, docstrings, or prose.- # Multiple patterns cover subprocess.run/Popen/call/check_output/check_call,- # os.system, and asyncio.create_subprocess_exec/shell.- patterns = [re.compile(p) for p in _SUBPROCESS_PATTERNS]-- for i, line in enumerate(lines):- # Skip comments.- stripped = line.lstrip()- if stripped.startswith("#"):+ violations = []+ for node in ast.walk(tree):+ if not isinstance(node, ast.Call) or not _is_inheriting_call(node):continue-- # Skip lines where the match is inside backticks (docstring references).- if "``subprocess" in line:+ if _call_is_safe(node, tree):continue-- if not any(p.search(line) for p in patterns):+ # Inline exemption marker on the call itself or within the few comment+ # lines immediately above it → the call intentionally inherits stdin.+ start, end = node.lineno - 1, node.end_lineno or node.lineno+ if EXEMPT_MARKER in "\n".join(lines[max(0, start - 4):end]):continue+ violations.append({+ "file": filepath,+ "line": node.lineno,+ "snippet": lines[start].strip()[:120],+ })- # Collect the full call (may span multiple lines).- call_start = i- paren_depth = 0- found_open = False- call_lines = []- for j in range(i, min(i + 30, len(lines))):- call_lines.append(lines[j])- for ch in lines[j]:- if ch == "(":- paren_depth += 1- found_open = True- elif ch == ")":- paren_depth -= 1- if found_open and paren_depth == 0:- call_text = "\n".join(call_lines)-- # Already has stdin= → safe.- if "stdin=" in call_text:- break-- # Has input= → creates a pipe, safe.- if "input=" in call_text:- break-- # Splats a same-file kwargs helper whose definition- # sets stdin= → the guard travels with the helper.- if _splat_carries_stdin(call_text, content):- break-- # Inline exemption marker on the call itself or within- # the few comment lines immediately above it → the call- # intentionally inherits stdin.- window_start = max(0, i - 4)- preceding = "\n".join(lines[window_start:i])- if EXEMPT_MARKER in call_text or EXEMPT_MARKER in preceding:- break-- violations.append({- "file": filepath,- "line": i + 1,- "snippet": line.strip()[:120],- })- break- else:- continue- break-+ violations.sort(key=lambda v: v["line"])return violationsdiff --git a/tests/tools/test_subprocess_stdin_guard.py b/tests/tools/test_subprocess_stdin_guard.pyindex c2b070e688c..a929162fce7 100644--- a/tests/tools/test_subprocess_stdin_guard.py+++ b/tests/tools/test_subprocess_stdin_guard.py@@ -86,3 +86,12 @@ def test_splatted_kwargs_helper_counts_only_when_it_sets_stdin():assert len(guard.find_subprocess_calls(unsafe_const, "x.py")) == 1assert len(guard.find_subprocess_calls(undefined, "x.py")) == 1assert [v["line"] for v in guard.find_subprocess_calls(unrelated_later, "x.py")] == [3]+++def test_call_with_arguments_on_the_next_line_is_checked():+ """A call whose arguments start on the line after ``(`` is found and checked."""+ guard = _load_guard()+ multiline = "import subprocess\nsubprocess.run(\n ['ffmpeg', '-y'],\n check=True,\n)\n"+ assert [v["line"] for v in guard.find_subprocess_calls(multiline, "x.py")] == [2]+ fixed = multiline.replace("check=True,", "stdin=subprocess.DEVNULL, check=True,")+ assert guard.find_subprocess_calls(fixed, "x.py") == []diff --git a/tools/process_registry.py b/tools/process_registry.pyindex 43a4fbf4a0c..bb7f60ddd79 100644--- a/tools/process_registry.py+++ b/tools/process_registry.py@@ -282,7 +282,7 @@ def _systemd_run_user_scope_available() -> bool:for _attempt in range(2):result = subprocess.run(_systemd_scope_argv(binary, probe_unit, "/bin/sh", "-c", "exit 0"),- capture_output=True,+ stdin=subprocess.DEVNULL, capture_output=True,timeout=3,env=systemd_user_bus_env(),)diff --git a/tools/read_extract.py b/tools/read_extract.pyindex 09dcca808c0..2adc191ad24 100644--- a/tools/read_extract.py+++ b/tools/read_extract.py@@ -256,7 +256,7 @@ def _pdf_page_texts(path: str) -> Optional[list[str]]:return Nonetry:proc = subprocess.run(- ["pdftotext", path, "-"], capture_output=True, timeout=PDF_PAGE_SCAN_TIMEOUT)+ ["pdftotext", path, "-"], stdin=subprocess.DEVNULL, capture_output=True, timeout=PDF_PAGE_SCAN_TIMEOUT)except (OSError, subprocess.SubprocessError):return Noneout = proc.stdout.decode("utf-8", errors="replace") if proc.returncode == 0 else ""diff --git a/tools/self_repo_guard.py b/tools/self_repo_guard.pyindex f0fb5aa1691..df8959061b1 100644--- a/tools/self_repo_guard.py+++ b/tools/self_repo_guard.py@@ -446,7 +446,7 @@ def _read_git_alias(executable: str, target: Path, alias: str) -> str | None:with contextlib.suppress(OSError, subprocess.SubprocessError):result = subprocess.run([executable, "-C", str(target), "config", "--get", f"alias.{alias}"],- capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=1, check=False)+ stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=1, check=False)return (result.stdout.strip() or None) if result.returncode == 0 else Nonereturn Nonediff --git a/tui_gateway/host_supervisor.py b/tui_gateway/host_supervisor.pyindex 8afd6edb376..6e2f9aa26bb 100644--- a/tui_gateway/host_supervisor.py+++ b/tui_gateway/host_supervisor.py@@ -82,7 +82,7 @@ def _check_output(argv: list[str], **kwargs: Any) -> str:"""Stripped stdout of a short subprocess, or ``""`` on any failure."""with contextlib.suppress(Exception):return subprocess.check_output(- argv, text=True, encoding="utf-8", errors="replace", stderr=subprocess.DEVNULL,+ argv, stdin=subprocess.DEVNULL, text=True, encoding="utf-8", errors="replace", stderr=subprocess.DEVNULL,timeout=2, **kwargs).strip()return ""