Move tty into container.json

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-02-21 13:53:11 -08:00
parent 6054bda2b8
commit d67915851d
5 changed files with 11 additions and 12 deletions

View file

@ -18,7 +18,7 @@ import (
// Exec performes setup outside of a namespace so that a container can be
// executed. Exec is a high level function for working with container namespaces.
func Exec(container *libcontainer.Container, tty bool, args []string) (int, error) {
func Exec(container *libcontainer.Container, args []string) (int, error) {
var (
master *os.File
console string
@ -28,7 +28,7 @@ func Exec(container *libcontainer.Container, tty bool, args []string) (int, erro
outPipe, errPipe io.ReadCloser
)
if tty {
if container.Tty {
master, console, err = createMasterAndConsole()
if err != nil {
return -1, err
@ -44,7 +44,7 @@ func Exec(container *libcontainer.Container, tty bool, args []string) (int, erro
system.UsetCloseOnExec(r.Fd())
command := createCommand(container, console, r.Fd(), args)
if !tty {
if !container.Tty {
if inPipe, err = command.StdinPipe(); err != nil {
return -1, err
}
@ -86,7 +86,7 @@ func Exec(container *libcontainer.Container, tty bool, args []string) (int, erro
w.Close()
r.Close()
if tty {
if container.Tty {
go io.Copy(os.Stdout, master)
go io.Copy(master, os.Stdin)

View file

@ -14,7 +14,6 @@ import (
var (
console string
tty bool
pipeFd int
)
@ -25,7 +24,6 @@ var (
func init() {
flag.StringVar(&console, "console", "", "console (pty slave) path")
flag.BoolVar(&tty, "tty", false, "create a tty")
flag.IntVar(&pipeFd, "pipe", 0, "sync pipe fd")
flag.Parse()
@ -52,7 +50,7 @@ func main() {
if nspid > 0 {
exitCode, err = nsinit.ExecIn(container, nspid, flag.Args()[1:])
} else {
exitCode, err = nsinit.Exec(container, tty, flag.Args()[1:])
exitCode, err = nsinit.Exec(container, flag.Args()[1:])
}
if err != nil {
log.Fatal(err)