Blame SOURCES/sos-bz2079492-timeouted-exec-cmd-exception.patch

7701ef
From 5e27b92a8a9f066af4c41ddd0bedc7c69187ff52 Mon Sep 17 00:00:00 2001
7701ef
From: Pavel Moravec <pmoravec@redhat.com>
7701ef
Date: Mon, 2 May 2022 22:13:34 +0200
7701ef
Subject: [PATCH] [utilities] Close file only when storing to file
7701ef
7701ef
Call _output.close() only when to_file=true.
7701ef
7701ef
Closes: #2925
7701ef
7701ef
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
7701ef
---
7701ef
 sos/utilities.py | 3 ++-
7701ef
 1 file changed, 2 insertions(+), 1 deletion(-)
7701ef
7701ef
diff --git a/sos/utilities.py b/sos/utilities.py
7701ef
index d2f73d86..1075d1d4 100644
7701ef
--- a/sos/utilities.py
7701ef
+++ b/sos/utilities.py
7701ef
@@ -212,7 +212,8 @@ def sos_get_command_output(command, timeout=TIMEOUT_DEFAULT, stderr=False,
7701ef
                 p.wait(timeout if timeout else None)
7701ef
             except Exception:
7701ef
                 p.terminate()
7701ef
-                _output.close()
7701ef
+                if to_file:
7701ef
+                    _output.close()
7701ef
                 # until we separate timeouts from the `timeout` command
7701ef
                 # handle per-cmd timeouts via Plugin status checks
7701ef
                 return {'status': 124, 'output': reader.get_contents(),
7701ef
-- 
7701ef
2.34.3
7701ef