Browse code

Merge pull request #913 from dotcloud/fix_detach_eof

- Runtime: Impossible to detach from attached container fix

Guillaume J. Charmes authored on 2013/06/21 02:21:19
Showing 1 changed files
... ...
@@ -1065,37 +1065,18 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
1065 1065
 		return fmt.Errorf("Impossible to attach to a stopped container, start it first")
1066 1066
 	}
1067 1067
 
1068
-	splitStderr := container.Config.Tty
1069
-
1070
-	connections := 1
1071
-	if splitStderr {
1072
-		connections += 1
1073
-	}
1074
-	chErrors := make(chan error, connections)
1075 1068
 	if container.Config.Tty {
1076 1069
 		cli.monitorTtySize(cmd.Arg(0))
1077 1070
 	}
1078
-	if splitStderr {
1079
-		go func() {
1080
-			chErrors <- cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?stream=1&stderr=1", false, nil, os.Stderr)
1081
-		}()
1082
-	}
1071
+
1083 1072
 	v := url.Values{}
1084 1073
 	v.Set("stream", "1")
1085 1074
 	v.Set("stdin", "1")
1086 1075
 	v.Set("stdout", "1")
1087
-	if !splitStderr {
1088
-		v.Set("stderr", "1")
1089
-	}
1090
-	go func() {
1091
-		chErrors <- cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), container.Config.Tty, os.Stdin, os.Stdout)
1092
-	}()
1093
-	for connections > 0 {
1094
-		err := <-chErrors
1095
-		if err != nil {
1096
-			return err
1097
-		}
1098
-		connections -= 1
1076
+	v.Set("stderr", "1")
1077
+
1078
+	if err := cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), container.Config.Tty, os.Stdin, os.Stdout); err != nil {
1079
+		return err
1099 1080
 	}
1100 1081
 	return nil
1101 1082
 }