Open with NOCTTY and set raw term

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-07-15 17:19:32 -07:00
parent d661720fd7
commit 43b4258c46
1 changed files with 15 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/docker/libcontainer"
consolepkg "github.com/docker/libcontainer/console"
"github.com/docker/libcontainer/namespaces"
"github.com/dotcloud/docker/pkg/term"
)
var execCommand = cli.Command{
@ -87,7 +88,7 @@ func startContainer(container *libcontainer.Config, dataPath string, args []stri
return -1, err
}
slave, err := consolepkg.OpenTerminal(slavePath, syscall.O_RDWR)
slave, err := consolepkg.OpenTerminal(slavePath, syscall.O_RDWR|syscall.O_NOCTTY)
if err != nil {
return -1, err
}
@ -96,6 +97,19 @@ func startContainer(container *libcontainer.Config, dataPath string, args []stri
go io.Copy(master, os.Stdin)
go io.Copy(os.Stdout, master)
ws, err := term.GetWinsize(os.Stdin.Fd())
if err != nil {
return -1, err
}
if err := term.SetWinsize(master.Fd(), ws); err != nil {
return -1, err
}
if _, err := term.SetRawTerminal(os.Stdin.Fd()); err != nil {
return -1, err
}
}
return namespaces.Exec(container, stdin, stdout, stderr, "", dataPath, args, createCommand, startCallback)