1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add debug infos

This commit is contained in:
Guillaume J. Charmes 2013-03-29 08:18:43 -07:00
parent b013d93786
commit ccac5b1382
2 changed files with 29 additions and 3 deletions

View file

@ -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
}

View file

@ -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