diff options
Diffstat (limited to 'cmd/podman/utils.go')
-rw-r--r-- | cmd/podman/utils.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go index fdb720cec..522b74926 100644 --- a/cmd/podman/utils.go +++ b/cmd/podman/utils.go @@ -46,6 +46,19 @@ func attachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys defer restoreTerminal(oldTermState) } + // There may be on the other size of the resize channel a goroutine trying to send. + // So consume all data inside the channel before exiting to avoid a deadlock. + defer func() { + for { + select { + case <-resize: + logrus.Debugf("Consumed resize command from channel") + default: + return + } + } + }() + streams := new(libpod.AttachStreams) streams.OutputStream = stdout streams.ErrorStream = stderr @@ -103,6 +116,19 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac defer restoreTerminal(oldTermState) } + // There may be on the other size of the resize channel a goroutine trying to send. + // So consume all data inside the channel before exiting to avoid a deadlock. + defer func() { + for { + select { + case <-resize: + logrus.Debugf("Consumed resize command from channel") + default: + return + } + } + }() + streams := new(libpod.AttachStreams) streams.OutputStream = stdout streams.ErrorStream = stderr |