Merge pull request #418 from mlaventure/ctr-term-handling
ctr: set raw mode when using --tty
This commit is contained in:
commit
f082890e46
1 changed files with 17 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/containerd/api/execution"
|
"github.com/docker/containerd/api/execution"
|
||||||
execEvents "github.com/docker/containerd/execution"
|
execEvents "github.com/docker/containerd/execution"
|
||||||
|
"github.com/docker/docker/pkg/term"
|
||||||
"github.com/nats-io/go-nats"
|
"github.com/nats-io/go-nats"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
@ -98,6 +99,21 @@ var runCommand = cli.Command{
|
||||||
Stderr: filepath.Join(tmpDir, "stderr"),
|
Stderr: filepath.Join(tmpDir, "stderr"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldState *term.State
|
||||||
|
restoreTerm := func() {
|
||||||
|
if oldState != nil {
|
||||||
|
term.RestoreTerminal(os.Stdin.Fd(), oldState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if crOpts.Console {
|
||||||
|
oldState, err = term.SetRawTerminal(os.Stdin.Fd())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer restoreTerm()
|
||||||
|
}
|
||||||
|
|
||||||
fwg, err := prepareStdio(crOpts.Stdin, crOpts.Stdout, crOpts.Stderr, crOpts.Console)
|
fwg, err := prepareStdio(crOpts.Stdin, crOpts.Stdout, crOpts.Stderr, crOpts.Console)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -143,6 +159,7 @@ var runCommand = cli.Command{
|
||||||
// Ensure we read all io
|
// Ensure we read all io
|
||||||
fwg.Wait()
|
fwg.Wait()
|
||||||
|
|
||||||
|
restoreTerm()
|
||||||
os.Exit(int(ec))
|
os.Exit(int(ec))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue