From: relan Date: Mon, 5 Feb 2018 12:34:42 +0000 (+0300) Subject: common: use /dev/null as stdin when calling subprocess.Popen() X-Git-Tag: 1.0.1~23^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=946a1461f2c60bb043f8e078421beef35f6919c0;p=fdroidserver.git common: use /dev/null as stdin when calling subprocess.Popen() 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. --- diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 352b22b1..d97cede3 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -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))