From 908c6e458b465ac6df09a7ff661d772482c9bece Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Sat, 22 Jun 2024 00:34:51 +0100 Subject: [PATCH] [common] handle all_logs when snap package is installed When using `_outfile` in the first `Popen` and the command beig run is a snap, then this will not work, and will not write to the file and will be blank. Dividing this into 2, and use `cat` as the second and grabbing it from the PIPE solves this problem. Resolves: #3683 Signed-off-by: Arif Ali --- sos/utilities.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sos/utilities.py b/sos/utilities.py index a69536b309..ebb3c654d3 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -282,10 +282,17 @@ def _check_poller(proc): expanded_args.append(arg) if to_file: _output = open(to_file, 'w') + prep_p = Popen(expanded_args, shell=False, stdout=PIPE, + stderr=STDOUT if stderr else PIPE, + bufsize=-1, env=cmd_env, close_fds=True, + preexec_fn=_child_prep_fn) + _stdin = prep_p.stdout + expanded_args = ['cat'] else: _output = PIPE + _stdin = None try: - p = Popen(expanded_args, shell=False, stdout=_output, + p = Popen(expanded_args, stdin=_stdin, shell=False, stdout=_output, stderr=STDOUT if stderr else PIPE, bufsize=-1, env=cmd_env, close_fds=True, preexec_fn=_child_prep_fn)