cmdmod.py: Don't reset output vars inside loop

The stdout and stderr variables are used to collect the output of
the command. These should not be reset inside the loop, because then the
output that was already collected gets lost.

Fixes: 60365
This commit is contained in:
Roel van Meer 2022-10-18 12:11:45 +02:00 committed by Megan Wilhite
parent ad2b54e337
commit 8a647033a8

View file

@ -838,6 +838,8 @@ def _run(
stream_stderr=True,
)
ret["pid"] = proc.pid
stdout = ""
stderr = ""
while proc.has_unread_data:
try:
try:
@ -848,12 +850,8 @@ def _run(
cstdout, cstderr = "", ""
if cstdout:
stdout += cstdout
else:
stdout = ""
if cstderr:
stderr += cstderr
else:
stderr = ""
if timeout and (time.time() > will_timeout):
ret["stderr"] = "SALT: Timeout after {}s\n{}".format(
timeout, stderr