@@ -14,9 +14,9 @@ import (
1414// newTty creates a new tty for use with the container. If a tty is not to be
1515// created for the process, pipes are created so that the TTY of the parent
1616// process are not inherited by the container.
17- func newTty(create bool, p *libcontainer.Process, rootuid int) (*tty, error) {
17+ func newTty(create bool, p *libcontainer.Process, rootuid int, console string ) (*tty, error) {
1818 if create {
19- return createTty(p, rootuid)
19+ return createTty(p, rootuid, console )
2020 }
2121 return createStdioPipes(p, rootuid)
2222}
@@ -41,13 +41,20 @@ func createStdioPipes(p *libcontainer.Process, rootuid int) (*tty, error) {
4141 return t, nil
4242}
4343
44- func createTty(p *libcontainer.Process, rootuid int) (*tty, error) {
44+ func createTty(p *libcontainer.Process, rootuid int, consolePath string) (*tty, error) {
45+ if consolePath != "" {
46+ if err := p.ConsoleFromPath(consolePath); err != nil {
47+ return nil, err
48+ }
49+ return &tty{}, nil
50+ }
4551 console, err := p.NewConsole(rootuid)
4652 if err != nil {
4753 return nil, err
4854 }
4955 go io.Copy(console, os.Stdin)
5056 go io.Copy(os.Stdout, console)
57+
5158 state, err := term.SetRawTerminal(os.Stdin.Fd())
5259 if err != nil {
5360 return nil, fmt.Errorf("failed to set the terminal from the stdin: %v", err)
0 commit comments