mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Store the master ptys in order to close them when the process dies (#228)
This commit is contained in:
parent
41555f67e0
commit
5252ab697c
1 changed files with 24 additions and 0 deletions
24
container.go
24
container.go
|
@ -40,6 +40,10 @@ type Container struct {
|
|||
stdin io.ReadCloser
|
||||
stdinPipe io.WriteCloser
|
||||
|
||||
ptyStdinMaster io.Closer
|
||||
ptyStdoutMaster io.Closer
|
||||
ptyStderrMaster io.Closer
|
||||
|
||||
runtime *Runtime
|
||||
}
|
||||
|
||||
|
@ -151,12 +155,14 @@ func (container *Container) startPty() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
container.ptyStdoutMaster = stdoutMaster
|
||||
container.cmd.Stdout = stdoutSlave
|
||||
|
||||
stderrMaster, stderrSlave, err := pty.Open()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
container.ptyStderrMaster = stderrMaster
|
||||
container.cmd.Stderr = stderrSlave
|
||||
|
||||
// Copy the PTYs to our broadcasters
|
||||
|
@ -181,6 +187,7 @@ func (container *Container) startPty() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
container.ptyStdinMaster = stdinMaster
|
||||
container.cmd.Stdin = stdinSlave
|
||||
// FIXME: The following appears to be broken.
|
||||
// "cannot set terminal process group (-1): Inappropriate ioctl for device"
|
||||
|
@ -380,6 +387,23 @@ func (container *Container) monitor() {
|
|||
if err := container.stderr.Close(); err != nil {
|
||||
Debugf("%s: Error close stderr: %s", container.Id, err)
|
||||
}
|
||||
|
||||
if container.ptyStdinMaster != nil {
|
||||
if err := container.ptyStdinMaster.Close(); err != nil {
|
||||
Debugf("%s: Error close pty stdin 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)
|
||||
}
|
||||
}
|
||||
|
||||
if err := container.Unmount(); err != nil {
|
||||
log.Printf("%v: Failed to umount filesystem: %v", container.Id, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue