diff --git a/linux_container.go b/linux_container.go index fffd7c67..a5eb9a98 100644 --- a/linux_container.go +++ b/linux_container.go @@ -100,7 +100,7 @@ func (c *linuxContainer) StartProcess(config *ProcessConfig) (int, error) { if state != configs.Destroyed { glog.Info("start new container process") - return namespaces.ExecIn(config.Args, config.Env, cmd, c.config, c.state) + return namespaces.ExecIn(config.Args, config.Env, config.Console, cmd, c.config, c.state) } if err := c.startInitProcess(cmd, config); err != nil { @@ -134,7 +134,7 @@ func (c *linuxContainer) updateStateFile() error { } func (c *linuxContainer) startInitProcess(cmd *exec.Cmd, config *ProcessConfig) error { - err := namespaces.Exec(config.Args, config.Env, cmd, c.config, c.cgroupManager, c.state) + err := namespaces.Exec(config.Args, config.Env, config.Console, cmd, c.config, c.cgroupManager, c.state) if err != nil { return err } diff --git a/namespaces/exec.go b/namespaces/exec.go index f9526c22..0fd31be0 100644 --- a/namespaces/exec.go +++ b/namespaces/exec.go @@ -19,7 +19,7 @@ import ( // Move this to libcontainer package. // Exec performs 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(args []string, env []string, command *exec.Cmd, container *configs.Config, cgroupManager cgroups.Manager, state *configs.State) error { +func Exec(args []string, env []string, console string, command *exec.Cmd, container *configs.Config, cgroupManager cgroups.Manager, state *configs.State) error { var err error // create a pipe so that we can syncronize with the namespaced process and @@ -54,8 +54,9 @@ func Exec(args []string, env []string, command *exec.Cmd, container *configs.Con } process := processArgs{ - Env: append(env[0:], container.Env...), - Args: args, + Env: append(env[0:], container.Env...), + Args: args, + ConsolePath: console, } if err := encoder.Encode(process); err != nil { return terminate(err) diff --git a/namespaces/execin.go b/namespaces/execin.go index 5d2708ac..9b5b42c0 100644 --- a/namespaces/execin.go +++ b/namespaces/execin.go @@ -18,7 +18,7 @@ import ( // ExecIn reexec's cmd with _LIBCONTAINER_INITPID=PID so that it is able to run the // setns code in a single threaded environment joining the existing containers' namespaces. -func ExecIn(args []string, env []string, cmd *exec.Cmd, container *configs.Config, state *configs.State) (int, error) { +func ExecIn(args []string, env []string, console string, cmd *exec.Cmd, container *configs.Config, state *configs.State) (int, error) { var err error parent, child, err := newInitPipe() @@ -50,8 +50,9 @@ func ExecIn(args []string, env []string, cmd *exec.Cmd, container *configs.Confi } process := processArgs{ - Env: append(env[0:], container.Env...), - Args: args, + Env: append(env[0:], container.Env...), + Args: args, + ConsolePath: console, } if err := encoder.Encode(process); err != nil { return terminate(err) diff --git a/process.go b/process.go index 924de2ec..cd72b129 100644 --- a/process.go +++ b/process.go @@ -21,4 +21,7 @@ type ProcessConfig struct { Stdin io.Reader Stdout io.Writer Stderr io.Writer + + // Console is the path to the pty slave for use by the master + Console string }