Browse code

Fix the attach behavior with -i

Guillaume J. Charmes authored on 2013/09/24 09:53:02
Showing 1 changed files
... ...
@@ -473,13 +473,11 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
473 473
 				utils.Debugf("[start] attach stdout\n")
474 474
 				defer utils.Debugf("[end]  attach stdout\n")
475 475
 				// If we are in StdinOnce mode, then close stdin
476
-				if container.Config.StdinOnce {
477
-					if stdin != nil {
478
-						defer stdin.Close()
479
-					}
480
-					if stdinCloser != nil {
481
-						defer stdinCloser.Close()
482
-					}
476
+				if container.Config.StdinOnce && stdin != nil {
477
+					defer stdin.Close()
478
+				}
479
+				if stdinCloser != nil {
480
+					defer stdinCloser.Close()
483 481
 				}
484 482
 				_, err := io.Copy(stdout, cStdout)
485 483
 				if err != nil {
... ...
@@ -511,13 +509,11 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
511 511
 				utils.Debugf("[start] attach stderr\n")
512 512
 				defer utils.Debugf("[end]  attach stderr\n")
513 513
 				// If we are in StdinOnce mode, then close stdin
514
-				if container.Config.StdinOnce {
515
-					if stdin != nil {
516
-						defer stdin.Close()
517
-					}
518
-					if stdinCloser != nil {
519
-						defer stdinCloser.Close()
520
-					}
514
+				if container.Config.StdinOnce && stdin != nil {
515
+					defer stdin.Close()
516
+				}
517
+				if stdinCloser != nil {
518
+					defer stdinCloser.Close()
521 519
 				}
522 520
 				_, err := io.Copy(stderr, cStderr)
523 521
 				if err != nil {