Blame SOURCES/sos-bz1627544-pipe-returncode.patch

fce3c4
From 17bcd2bcdb8de4818b361582ac4d833ff324f4ff Mon Sep 17 00:00:00 2001
fce3c4
From: "Bryn M. Reeves" <bmr@redhat.com>
fce3c4
Date: Mon, 10 Sep 2018 18:06:00 +0100
fce3c4
Subject: [PATCH] [utilities] wait until AsyncReader p.poll() returns None
fce3c4
fce3c4
On some systems the pipe used by the AsyncReader() class and the
fce3c4
sos_get_command_output() function may still be open at the time
fce3c4
the p.poll() call returns. At this time the command exit status
fce3c4
is undefined, leading to errors and collection failures for code
fce3c4
that tests the command's exit code.
fce3c4
fce3c4
Wait explicitly until poll() returns None to avoid this.
fce3c4
fce3c4
Resolves: #1417
fce3c4
fce3c4
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
fce3c4
---
fce3c4
 sos/utilities.py | 3 ++-
fce3c4
 1 file changed, 2 insertions(+), 1 deletion(-)
fce3c4
fce3c4
diff --git a/sos/utilities.py b/sos/utilities.py
fce3c4
index d112e15a..25e10429 100644
fce3c4
--- a/sos/utilities.py
fce3c4
+++ b/sos/utilities.py
fce3c4
@@ -155,7 +155,8 @@ def sos_get_command_output(command, timeout=300, stderr=False,
fce3c4
 
fce3c4
         reader = AsyncReader(p.stdout, sizelimit, binary)
fce3c4
         stdout = reader.get_contents()
fce3c4
-        p.poll()
fce3c4
+        while p.poll() == None:
fce3c4
+            pass
fce3c4
 
fce3c4
     except OSError as e:
fce3c4
         if e.errno == errno.ENOENT:
fce3c4
-- 
fce3c4
2.17.1
fce3c4