diff options
author | Vincent Demeester <vincent@sbr.pm> | 2016-06-12 13:01:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-12 13:01:20 +0200 |
commit | 4dafd107ad0cb89e1a7f9e3bcc66fb6a5a5c99c5 (patch) | |
tree | f8089da3e613af8ded1ca48d50bb4ddbc7319cb2 /daemon/attach.go | |
parent | 434a46e6522b6fd143eb6842f57d126f772ff045 (diff) | |
parent | c498d4700df8216ccefd6d2f03b5ebe6d6e9fd47 (diff) | |
download | docker-4dafd107ad0cb89e1a7f9e3bcc66fb6a5a5c99c5.tar.gz |
Merge pull request #22777 from WeiZhang555/wait-restarting
Bug fix: `docker run -i --restart always` hangs
Diffstat (limited to 'daemon/attach.go')
-rw-r--r-- | daemon/attach.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/daemon/attach.go b/daemon/attach.go index 06eb2be3d4..3d4a51eead 100644 --- a/daemon/attach.go +++ b/daemon/attach.go @@ -119,6 +119,15 @@ func (daemon *Daemon) containerAttach(c *container.Container, stdin io.ReadClose }() stdinPipe = r } + + waitChan := make(chan struct{}) + if c.Config.StdinOnce && !c.Config.Tty { + go func() { + c.WaitStop(-1 * time.Second) + close(waitChan) + }() + } + err := <-c.Attach(stdinPipe, stdout, stderr, keys) if err != nil { if _, ok := err.(container.DetachError); ok { @@ -131,7 +140,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, stdin io.ReadClose // If we are in stdinonce mode, wait for the process to end // otherwise, simply return if c.Config.StdinOnce && !c.Config.Tty { - c.WaitStop(-1 * time.Second) + <-waitChan } } return nil |