Skip to content

Commit

Permalink
[common] handle all_logs when snap package is installed
Browse files Browse the repository at this point in the history
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: sosreport#3683

Signed-off-by: Arif Ali <[email protected]>
  • Loading branch information
arif-ali committed Jun 27, 2024
1 parent f1602d0 commit 908c6e4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sos/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 908c6e4

Please sign in to comment.