mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
ssh commands: improve command ended detection
Sometime we can have this error: read |0: file already closed reading from the command standard error, this means that the command is already finished so we don't need to do nothing. This happen randomically while running the test cases on travis.
This commit is contained in:
@@ -261,7 +261,8 @@ func (c *sshCommand) executeSystemCommand(command systemCommand) error {
|
||||
w, e := transfer.copyFromReaderToWriter(c.connection.channel.Stderr(), stderr, 0)
|
||||
c.connection.Log(logger.LevelDebug, logSenderSSH, "command: %#v, copy from sdterr to remote command ended, written: %v err: %v",
|
||||
c.connection.command, w, e)
|
||||
if e != nil || w > 0 {
|
||||
// os.ErrClosed means that the command is finished so we don't need to to nothing
|
||||
if (e != nil && !errors.Is(e, os.ErrClosed)) || w > 0 {
|
||||
once.Do(closeCmdOnError)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user