diff --git a/commands.go b/commands.go index cd91d07cff..c09bbd0034 100644 --- a/commands.go +++ b/commands.go @@ -798,20 +798,35 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...stri return err } wg.Add(1) - go func() { io.Copy(cStdin, stdin); wg.Add(-1) }() + go func() { + Debugf("Begin stdin pipe [attach]") + io.Copy(cStdin, stdin) + wg.Add(-1) + Debugf("End of stdin pipe [attach]") + }() } cStdout, err := container.StdoutPipe() if err != nil { return err } wg.Add(1) - go func() { io.Copy(stdout, cStdout); wg.Add(-1) }() + go func() { + Debugf("Begin stdout pipe [attach]") + io.Copy(stdout, cStdout) + wg.Add(-1) + Debugf("End of stdout pipe [attach]") + }() cStderr, err := container.StderrPipe() if err != nil { return err } wg.Add(1) - go func() { io.Copy(stdout, cStderr); wg.Add(-1) }() + go func() { + Debugf("Begin stderr pipe [attach]") + io.Copy(stdout, cStderr) + wg.Add(-1) + Debugf("End of stderr pipe [attach]") + }() wg.Wait() return nil } diff --git a/container.go b/container.go index c0175b96b1..ace99936da 100644 --- a/container.go +++ b/container.go @@ -165,12 +165,16 @@ func (container *Container) startPty() error { // Copy the PTYs to our broadcasters go func() { defer container.stdout.Close() + Debugf("[startPty] Begin of stdout pipe") io.Copy(container.stdout, stdoutMaster) + Debugf("[startPty] End of stdout pipe") }() go func() { defer container.stderr.Close() + Debugf("[startPty] Begin of stderr pipe") io.Copy(container.stderr, stderrMaster) + Debugf("[startPty] End of stderr pipe") }() // stdin @@ -186,7 +190,9 @@ func (container *Container) startPty() error { // container.cmd.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true} go func() { defer container.stdin.Close() + Debugf("[startPty] Begin of stdin pipe") io.Copy(stdinMaster, container.stdin) + Debugf("[startPty] End of stdin pipe") }() } if err := container.cmd.Start(); err != nil { @@ -210,7 +216,9 @@ func (container *Container) start() error { } go func() { defer stdin.Close() + Debugf("Begin of stdin pipe [start]") io.Copy(stdin, container.stdin) + Debugf("End of stdin pipe [start]") }() } return container.cmd.Start() @@ -348,7 +356,10 @@ func (container *Container) releaseNetwork() error { func (container *Container) monitor() { // Wait for the program to exit + Debugf("Waiting for process") container.cmd.Wait() + Debugf("Process finished") + exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() // Cleanup