make sure subprocesses by defaulit don't inherit stdin FD

This commit is contained in:
holger krekel
2026-03-10 10:54:27 +01:00
parent da5c248562
commit dcb9fbe73f
2 changed files with 3 additions and 1 deletions

View File

@@ -128,7 +128,7 @@ class Incus:
proc = subprocess.Popen(
cmd,
text=True,
stdin=subprocess.PIPE if input else None,
stdin=subprocess.PIPE if input else subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)

View File

@@ -90,6 +90,7 @@ class Out:
cmd,
shell=True,
text=True,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env=env,
@@ -133,6 +134,7 @@ def shell(cmd, check=False, **kwargs):
"""
if "capture_output" not in kwargs and "stdout" not in kwargs:
kwargs["capture_output"] = True
kwargs.setdefault("stdin", subprocess.DEVNULL)
return subprocess.run(collapse(cmd), shell=True, text=True, check=check, **kwargs)