summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2021-03-10 14:50:59 +0200
committerSimon McVittie <smcv@debian.org>2023-01-22 12:42:44 +0000
commitc1e6b93e66b590d2e28aa5d6753371c70a86d0af (patch)
treed0d9cf09250b2646a47990508c3b45e2a5c8bc75
parente5f811a3e1db2608ecd35ec984ad9def47331a44 (diff)
Do not use subprocess pipe
We use the 'subprocess' module for running external processes, and in few places we create sub-processes with the 'stderr=subprocess.PIPE' argument. Howerver, we never read from the pipe, which means that it may get filled and block the external program. This is dangerous and may lead to deadlock situations. This patch fixes the issue by removing the argument. If we do not read sub-process's 'stderr', it is OK for it to inherit it from the main program, so the error message will just go to bmaptool's standare error stream. Origin: upstream, 3.7, commit:d77f3e9a6e496ba8d460f27bfef02aec45181b78 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Gbp-Pq: Name Do-not-use-subprocess-pipe.patch
-rw-r--r--bmaptools/TransRead.py6
-rw-r--r--tests/test_api_base.py4
2 files changed, 3 insertions, 7 deletions
diff --git a/bmaptools/TransRead.py b/bmaptools/TransRead.py
index 1d0b582..cdfd37e 100644
--- a/bmaptools/TransRead.py
+++ b/bmaptools/TransRead.py
@@ -419,8 +419,7 @@ class TransRead(object):
child_process = subprocess.Popen(args, shell=True,
bufsize=1024 * 1024,
stdin=child_stdin,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stdout=subprocess.PIPE)
if child_stdin == subprocess.PIPE:
# A separate reader thread is created only when we are reading via
@@ -490,8 +489,7 @@ class TransRead(object):
# host
command = "test -f " + path + " && test -r " + path
child_process = subprocess.Popen(popen_args + [command],
- bufsize=1024 * 1024,
- stdout=subprocess.PIPE)
+ bufsize=1024 * 1024)
child_process.wait()
if child_process.returncode != 0:
raise Error("\"%s\" on \"%s\" cannot be read: make sure it "
diff --git a/tests/test_api_base.py b/tests/test_api_base.py
index ea996c7..11adeaa 100644
--- a/tests/test_api_base.py
+++ b/tests/test_api_base.py
@@ -116,9 +116,7 @@ def _generate_compressed_files(file_path, delete=True):
args = archiver + " " + options + " " + file_path
else:
args = decompressor + " " + options + " " + file_path
- child_process = subprocess.Popen(args, shell=True,
- stderr=subprocess.PIPE,
- stdout=tmp_file_obj)
+ child_process = subprocess.Popen(args, shell=True, stdout=tmp_file_obj)
child_process.wait()
tmp_file_obj.flush()
yield tmp_file_obj.name