From 64c1b6d9cd16b7d4cc8ebda2de82bc76e0c99f43 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 9 Apr 2013 08:18:16 -0700 Subject: [PATCH 1/2] Change the behaviour of CmdRun in tty mode: dont kill the process uppon detach --- container.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/container.go b/container.go index 6b3913522c..34ca696ed8 100644 --- a/container.go +++ b/container.go @@ -250,10 +250,7 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s if cStderr != nil { defer cStderr.Close() } - if container.Config.StdinOnce { - if container.Config.Tty { - defer container.Kill() - } + if container.Config.StdinOnce && !container.Config.Tty { defer cStdin.Close() } _, err := io.Copy(cStdin, stdin) From d063d52cce9892c777722b30923d9fb1f1385fe8 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 9 Apr 2013 08:18:36 -0700 Subject: [PATCH 2/2] Update the unit test to reflect the new CmdRun behaviour in tty mode --- commands_test.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/commands_test.go b/commands_test.go index 4592ea77ac..30e2579d20 100644 --- a/commands_test.go +++ b/commands_test.go @@ -228,15 +228,13 @@ func TestRunDisconnectTty(t *testing.T) { <-c1 }) - // Client disconnect after run -i should cause stdin to be closed, which should - // cause /bin/cat to exit. - setTimeout(t, "Waiting for /bin/cat to exit timed out", 2*time.Second, func() { - container := runtime.List()[0] - container.Wait() - if container.State.Running { - t.Fatalf("/bin/cat is still running after closing stdin") - } - }) + // Client disconnect after run -i should keep stdin out in TTY mode + container := runtime.List()[0] + // Give some time to monitor to do his thing + container.WaitTimeout(500 * time.Millisecond) + if !container.State.Running { + t.Fatalf("/bin/cat should still be running after closing stdin (tty mode)") + } } // TestAttachStdin checks attaching to stdin without stdout and stderr.