github.com/circular-dark/docker@v1.7.0/daemon/execdriver/termconsole.go (about) 1 package execdriver 2 3 import ( 4 "io" 5 "os/exec" 6 ) 7 8 type StdConsole struct { 9 } 10 11 func NewStdConsole(processConfig *ProcessConfig, pipes *Pipes) (*StdConsole, error) { 12 std := &StdConsole{} 13 14 if err := std.AttachPipes(&processConfig.Cmd, pipes); err != nil { 15 return nil, err 16 } 17 return std, nil 18 } 19 20 func (s *StdConsole) AttachPipes(command *exec.Cmd, pipes *Pipes) error { 21 command.Stdout = pipes.Stdout 22 command.Stderr = pipes.Stderr 23 24 if pipes.Stdin != nil { 25 stdin, err := command.StdinPipe() 26 if err != nil { 27 return err 28 } 29 30 go func() { 31 defer stdin.Close() 32 io.Copy(stdin, pipes.Stdin) 33 }() 34 } 35 return nil 36 } 37 38 func (s *StdConsole) Resize(h, w int) error { 39 // we do not need to reside a non tty 40 return nil 41 } 42 43 func (s *StdConsole) Close() error { 44 // nothing to close here 45 return nil 46 }