From 29ced936a6a31761e44cef6bc9e14ab1b091cb28 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Wed, 19 Aug 2015 17:28:51 +0800 Subject: [PATCH] richer information error message for terminal When we use ```cat | runc``` or ```runc /dev/stdin < config.json```, it will fail and output ```FATA[0000] Container start failed: inappropriate ioctl for device```. It is hard for the users to find out the reason from the message: the config.json enables the terminal but the user redirect the stdin to an non-terminal file. After this patch, the output will be ```FATA[0000] Container start failed: Failed to set the terminal from the stdin: inappropriate ioctl for device``` So the user can disable the terminal in the config.json. See the #202 Cc: W. Trevor King (@wking) Signed-off-by: Lai Jiangshan --- tty.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tty.go b/tty.go index cf879303..c919d417 100644 --- a/tty.go +++ b/tty.go @@ -3,6 +3,7 @@ package main import ( + "fmt" "io" "os" @@ -56,7 +57,7 @@ func createTty(p *libcontainer.Process, rootuid int) (*tty, error) { go io.Copy(os.Stdout, console) state, err := term.SetRawTerminal(os.Stdin.Fd()) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to set the terminal from the stdin: %v", err) } t := &tty{ console: console,