Skip to content

Commit

Permalink
Open with NOCTTY and set raw term
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
  • Loading branch information
Michael Crosby committed Jul 16, 2014
1 parent d661720 commit 43b4258
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion nsinit/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down

0 comments on commit 43b4258

Please sign in to comment.