chiark / gitweb /
common: use /dev/null as stdin when calling subprocess.Popen()
authorrelan <email@hidden>
Mon, 5 Feb 2018 12:34:42 +0000 (15:34 +0300)
committerrelan <email@hidden>
Mon, 5 Feb 2018 12:34:42 +0000 (15:34 +0300)
We always want to run all utilities non-interactively. By default
subprocess.Popen() inherits stdin descriptor from parent process, i.e.
when fdroid is run from an interactive shell, subprocesses may expect
input from it.

Reading from /dev/null immediately returns EOF, failing any user prompt
and preventing us from hang.

fdroidserver/common.py

index 352b22b1577c0af0003353bb1a9e634cb8dc78ee..d97cede329c2a5e8c7a250b59b601a350bbcaba6 100644 (file)
@@ -2024,7 +2024,8 @@ def FDroidPopenBytes(commands, cwd=None, envs=None, output=True, stderr_to_stdou
     p = None
     try:
         p = subprocess.Popen(commands, cwd=cwd, shell=False, env=process_env,
-                             stdout=subprocess.PIPE, stderr=stderr_param)
+                             stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
+                             stderr=stderr_param)
     except OSError as e:
         raise BuildException("OSError while trying to execute " +
                              ' '.join(commands) + ': ' + str(e))