Fix the attach behavior with -i

This commit is contained in:
Guillaume J. Charmes 2013-09-23 17:53:02 -07:00
parent f435970695
commit 537149829a
No known key found for this signature in database
GPG Key ID: B33E4642CB6E3FF3
1 changed files with 10 additions and 14 deletions

View File

@ -473,14 +473,12 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
utils.Debugf("[start] attach stdout\n") utils.Debugf("[start] attach stdout\n")
defer utils.Debugf("[end] attach stdout\n") defer utils.Debugf("[end] attach stdout\n")
// If we are in StdinOnce mode, then close stdin // If we are in StdinOnce mode, then close stdin
if container.Config.StdinOnce { if container.Config.StdinOnce && stdin != nil {
if stdin != nil {
defer stdin.Close() defer stdin.Close()
} }
if stdinCloser != nil { if stdinCloser != nil {
defer stdinCloser.Close() defer stdinCloser.Close()
} }
}
_, err := io.Copy(stdout, cStdout) _, err := io.Copy(stdout, cStdout)
if err != nil { if err != nil {
utils.Debugf("[error] attach stdout: %s\n", err) utils.Debugf("[error] attach stdout: %s\n", err)
@ -511,14 +509,12 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
utils.Debugf("[start] attach stderr\n") utils.Debugf("[start] attach stderr\n")
defer utils.Debugf("[end] attach stderr\n") defer utils.Debugf("[end] attach stderr\n")
// If we are in StdinOnce mode, then close stdin // If we are in StdinOnce mode, then close stdin
if container.Config.StdinOnce { if container.Config.StdinOnce && stdin != nil {
if stdin != nil {
defer stdin.Close() defer stdin.Close()
} }
if stdinCloser != nil { if stdinCloser != nil {
defer stdinCloser.Close() defer stdinCloser.Close()
} }
}
_, err := io.Copy(stderr, cStderr) _, err := io.Copy(stderr, cStderr)
if err != nil { if err != nil {
utils.Debugf("[error] attach stderr: %s\n", err) utils.Debugf("[error] attach stderr: %s\n", err)