From 1b7ad47ac19a3280c4a30fd28ab07f3aa64b7a2c Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Mon, 1 Feb 2016 04:38:37 -0500 Subject: [PATCH] Check IsTerminal before SetRawTerminal Do not set raw terminal if stdin is not a terminal Signed-off-by: Lei Jitang --- tty.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tty.go b/tty.go index 77d275afab0..d595be18a95 100644 --- a/tty.go +++ b/tty.go @@ -55,9 +55,12 @@ func createTty(p *libcontainer.Process, rootuid int, consolePath string) (*tty, go io.Copy(console, os.Stdin) go io.Copy(os.Stdout, console) - state, err := term.SetRawTerminal(os.Stdin.Fd()) - if err != nil { - return nil, fmt.Errorf("failed to set the terminal from the stdin: %v", err) + var state *term.State + if term.IsTerminal(os.Stdin.Fd()) { + state, err = term.SetRawTerminal(os.Stdin.Fd()) + if err != nil { + return nil, fmt.Errorf("failed to set the terminal from the stdin: %v", err) + } } t := &tty{ console: console,