From 537149829accde869430924cf988f64cfbd16f99 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Mon, 23 Sep 2013 17:53:02 -0700 Subject: [PATCH] Fix the attach behavior with -i --- container.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/container.go b/container.go index 2616fb221f..8ee5a68a9d 100644 --- a/container.go +++ b/container.go @@ -473,13 +473,11 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s utils.Debugf("[start] attach stdout\n") defer utils.Debugf("[end] attach stdout\n") // If we are in StdinOnce mode, then close stdin - if container.Config.StdinOnce { - if stdin != nil { - defer stdin.Close() - } - if stdinCloser != nil { - defer stdinCloser.Close() - } + if container.Config.StdinOnce && stdin != nil { + defer stdin.Close() + } + if stdinCloser != nil { + defer stdinCloser.Close() } _, err := io.Copy(stdout, cStdout) if err != nil { @@ -511,13 +509,11 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s utils.Debugf("[start] attach stderr\n") defer utils.Debugf("[end] attach stderr\n") // If we are in StdinOnce mode, then close stdin - if container.Config.StdinOnce { - if stdin != nil { - defer stdin.Close() - } - if stdinCloser != nil { - defer stdinCloser.Close() - } + if container.Config.StdinOnce && stdin != nil { + defer stdin.Close() + } + if stdinCloser != nil { + defer stdinCloser.Close() } _, err := io.Copy(stderr, cStderr) if err != nil {