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

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