Skip to content

Commit 17d04b8

Browse files
committed
[sshcmd] Fix race condition
Stdout should be written when the channel has already returned the result of the command.
1 parent 33d9ed8 commit 17d04b8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

plugins/teststeps/sshcmd/sshcmd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ func (ts *SSHCmd) Run(cancel, pause <-chan struct{}, ch test.TestStepChannels, p
185185
}()
186186

187187
// TODO should stdout/stderr go to events?
188-
log.Infof("Stdout of command '%s' is '%s'", cmd, stdout.Bytes())
189188
select {
190189
case err := <-errCh:
191-
log.Warningf("Stderr of command '%s' is '%s'", cmd, stderr.Bytes())
190+
log.Infof("Stdout of command '%s' is '%s'", cmd, stdout.Bytes())
191+
if err != nil {
192+
log.Warningf("Stderr of command '%s' is '%s'", cmd, stderr.Bytes())
193+
}
192194
return err
193195
case <-cancel:
194196
return session.Signal(ssh.SIGKILL)

0 commit comments

Comments
 (0)