mirror of
https://github.com/docker/cli.git
synced 2026-01-19 21:41:31 +03:00
Merge pull request #913 from dotcloud/fix_detach_eof
- Runtime: Impossible to detach from attached container fix Upstream-commit: d1a3d020aa7b843098aeb719e185cebf0822a3f2 Component: engine
This commit is contained in:
@@ -1065,37 +1065,18 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
|
||||
return fmt.Errorf("Impossible to attach to a stopped container, start it first")
|
||||
}
|
||||
|
||||
splitStderr := container.Config.Tty
|
||||
|
||||
connections := 1
|
||||
if splitStderr {
|
||||
connections += 1
|
||||
}
|
||||
chErrors := make(chan error, connections)
|
||||
if container.Config.Tty {
|
||||
cli.monitorTtySize(cmd.Arg(0))
|
||||
}
|
||||
if splitStderr {
|
||||
go func() {
|
||||
chErrors <- cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?stream=1&stderr=1", false, nil, os.Stderr)
|
||||
}()
|
||||
}
|
||||
|
||||
v := url.Values{}
|
||||
v.Set("stream", "1")
|
||||
v.Set("stdin", "1")
|
||||
v.Set("stdout", "1")
|
||||
if !splitStderr {
|
||||
v.Set("stderr", "1")
|
||||
}
|
||||
go func() {
|
||||
chErrors <- cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), container.Config.Tty, os.Stdin, os.Stdout)
|
||||
}()
|
||||
for connections > 0 {
|
||||
err := <-chErrors
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
connections -= 1
|
||||
v.Set("stderr", "1")
|
||||
|
||||
if err := cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), container.Config.Tty, os.Stdin, os.Stdout); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user