mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Cleanup pty variable names
This commit is contained in:
parent
33a5fe3bd4
commit
7d8895545e
1 changed files with 12 additions and 27 deletions
39
container.go
39
container.go
|
@ -40,9 +40,7 @@ type Container struct {
|
||||||
stdin io.ReadCloser
|
stdin io.ReadCloser
|
||||||
stdinPipe io.WriteCloser
|
stdinPipe io.WriteCloser
|
||||||
|
|
||||||
ptyStdinMaster io.Closer
|
ptyMaster io.Closer
|
||||||
ptyStdoutMaster io.Closer
|
|
||||||
ptyStderrMaster io.Closer
|
|
||||||
|
|
||||||
runtime *Runtime
|
runtime *Runtime
|
||||||
}
|
}
|
||||||
|
@ -180,40 +178,37 @@ func (container *Container) generateLXCConfig() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) startPty() error {
|
func (container *Container) startPty() error {
|
||||||
|
ptyMaster, ptySlave, err := pty.Open()
|
||||||
stdoutMaster, stdoutSlave, err := pty.Open()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.ptyStdoutMaster = stdoutMaster
|
container.ptyMaster = ptyMaster
|
||||||
container.cmd.Stdout = stdoutSlave
|
container.cmd.Stdout = ptySlave
|
||||||
container.cmd.Stderr = stdoutSlave
|
container.cmd.Stderr = ptySlave
|
||||||
|
|
||||||
// Copy the PTYs to our broadcasters
|
// Copy the PTYs to our broadcasters
|
||||||
go func() {
|
go func() {
|
||||||
defer container.stdout.CloseWriters()
|
defer container.stdout.CloseWriters()
|
||||||
Debugf("[startPty] Begin of stdout pipe")
|
Debugf("[startPty] Begin of stdout pipe")
|
||||||
io.Copy(container.stdout, stdoutMaster)
|
io.Copy(container.stdout, ptyMaster)
|
||||||
Debugf("[startPty] End of stdout pipe")
|
Debugf("[startPty] End of stdout pipe")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// stdin
|
// stdin
|
||||||
if container.Config.OpenStdin {
|
if container.Config.OpenStdin {
|
||||||
container.cmd.Stdin = stdoutSlave
|
container.cmd.Stdin = ptySlave
|
||||||
// FIXME: The following appears to be broken.
|
|
||||||
// "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(stdoutMaster, container.stdin)
|
io.Copy(ptyMaster, container.stdin)
|
||||||
Debugf("[startPty] End of stdin pipe")
|
Debugf("[startPty] End of stdin pipe")
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if err := container.cmd.Start(); err != nil {
|
if err := container.cmd.Start(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
stdoutSlave.Close()
|
ptySlave.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,19 +502,9 @@ func (container *Container) monitor() {
|
||||||
Debugf("%s: Error close stderr: %s", container.Id, err)
|
Debugf("%s: Error close stderr: %s", container.Id, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if container.ptyStdinMaster != nil {
|
if container.ptyMaster != nil {
|
||||||
if err := container.ptyStdinMaster.Close(); err != nil {
|
if err := container.ptyMaster.Close(); err != nil {
|
||||||
Debugf("%s: Error close pty stdin master: %s", container.Id, err)
|
Debugf("%s: Error closing Pty master: %s", container.Id, err)
|
||||||
}
|
|
||||||
}
|
|
||||||
if container.ptyStdoutMaster != nil {
|
|
||||||
if err := container.ptyStdoutMaster.Close(); err != nil {
|
|
||||||
Debugf("%s: Error close pty stdout master: %s", container.Id, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if container.ptyStderrMaster != nil {
|
|
||||||
if err := container.ptyStderrMaster.Close(); err != nil {
|
|
||||||
Debugf("%s: Error close pty stderr master: %s", container.Id, err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue