Merge the 3 ptys in 1
This commit is contained in:
parent
e9a68801ba
commit
847a8f45a4
31
container.go
31
container.go
|
@ -180,19 +180,14 @@ func (container *Container) generateLXCConfig() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) startPty() error {
|
func (container *Container) startPty() error {
|
||||||
|
|
||||||
stdoutMaster, stdoutSlave, err := pty.Open()
|
stdoutMaster, stdoutSlave, err := pty.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.ptyStdoutMaster = stdoutMaster
|
container.ptyStdoutMaster = stdoutMaster
|
||||||
container.cmd.Stdout = stdoutSlave
|
container.cmd.Stdout = stdoutSlave
|
||||||
|
container.cmd.Stderr = stdoutSlave
|
||||||
stderrMaster, stderrSlave, err := pty.Open()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
container.ptyStderrMaster = stderrMaster
|
|
||||||
container.cmd.Stderr = stderrSlave
|
|
||||||
|
|
||||||
// Copy the PTYs to our broadcasters
|
// Copy the PTYs to our broadcasters
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -202,30 +197,16 @@ func (container *Container) startPty() error {
|
||||||
Debugf("[startPty] End of stdout pipe")
|
Debugf("[startPty] End of stdout pipe")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
|
||||||
defer container.stderr.CloseWriters()
|
|
||||||
Debugf("[startPty] Begin of stderr pipe")
|
|
||||||
io.Copy(container.stderr, stderrMaster)
|
|
||||||
Debugf("[startPty] End of stderr pipe")
|
|
||||||
}()
|
|
||||||
|
|
||||||
// stdin
|
// stdin
|
||||||
var stdinSlave io.ReadCloser
|
|
||||||
if container.Config.OpenStdin {
|
if container.Config.OpenStdin {
|
||||||
var stdinMaster io.WriteCloser
|
container.cmd.Stdin = stdoutSlave
|
||||||
stdinMaster, stdinSlave, err = pty.Open()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
container.ptyStdinMaster = stdinMaster
|
|
||||||
container.cmd.Stdin = stdinSlave
|
|
||||||
// FIXME: The following appears to be broken.
|
// FIXME: The following appears to be broken.
|
||||||
// "cannot set terminal process group (-1): Inappropriate ioctl for device"
|
// "cannot set terminal process group (-1): Inappropriate ioctl for device"
|
||||||
// container.cmd.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true}
|
// container.cmd.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true}
|
||||||
go func() {
|
go func() {
|
||||||
defer container.stdin.Close()
|
defer container.stdin.Close()
|
||||||
Debugf("[startPty] Begin of stdin pipe")
|
Debugf("[startPty] Begin of stdin pipe")
|
||||||
io.Copy(stdinMaster, container.stdin)
|
io.Copy(stdoutMaster, container.stdin)
|
||||||
Debugf("[startPty] End of stdin pipe")
|
Debugf("[startPty] End of stdin pipe")
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -233,10 +214,6 @@ func (container *Container) startPty() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
stdoutSlave.Close()
|
stdoutSlave.Close()
|
||||||
stderrSlave.Close()
|
|
||||||
if stdinSlave != nil {
|
|
||||||
stdinSlave.Close()
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue