Merge pull request #1714 from littlejawa/issue_1713

runtime: Fix stdout/stderr output from container being truncated
This commit is contained in:
Fabiano Fidêncio 2021-04-22 23:00:47 +02:00 committed by GitHub
commit a4fffa1f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,7 +87,6 @@ func newTtyIO(ctx context.Context, stdin, stdout, stderr string, console bool) (
func ioCopy(exitch, stdinCloser chan struct{}, tty *ttyIO, stdinPipe io.WriteCloser, stdoutPipe, stderrPipe io.Reader) { func ioCopy(exitch, stdinCloser chan struct{}, tty *ttyIO, stdinPipe io.WriteCloser, stdoutPipe, stderrPipe io.Reader) {
var wg sync.WaitGroup var wg sync.WaitGroup
var closeOnce sync.Once
if tty.Stdin != nil { if tty.Stdin != nil {
wg.Add(1) wg.Add(1)
@ -109,7 +108,11 @@ func ioCopy(exitch, stdinCloser chan struct{}, tty *ttyIO, stdinPipe io.WriteClo
defer bufPool.Put(p) defer bufPool.Put(p)
io.CopyBuffer(tty.Stdout, stdoutPipe, *p) io.CopyBuffer(tty.Stdout, stdoutPipe, *p)
wg.Done() wg.Done()
closeOnce.Do(tty.close) if tty.Stdin != nil {
// close stdin to make the other routine stop
tty.Stdin.Close()
tty.Stdin = nil
}
}() }()
} }
@ -124,6 +127,6 @@ func ioCopy(exitch, stdinCloser chan struct{}, tty *ttyIO, stdinPipe io.WriteClo
} }
wg.Wait() wg.Wait()
closeOnce.Do(tty.close) tty.close()
close(exitch) close(exitch)
} }