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@tremily.us> (@wking) Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
This commit is contained in:
parent
d6ae10ada4
commit
29ced936a6
3
tty.go
3
tty.go
|
@ -3,6 +3,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ func createTty(p *libcontainer.Process, rootuid int) (*tty, error) {
|
||||||
go io.Copy(os.Stdout, console)
|
go io.Copy(os.Stdout, console)
|
||||||
state, err := term.SetRawTerminal(os.Stdin.Fd())
|
state, err := term.SetRawTerminal(os.Stdin.Fd())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to set the terminal from the stdin: %v", err)
|
||||||
}
|
}
|
||||||
t := &tty{
|
t := &tty{
|
||||||
console: console,
|
console: console,
|
||||||
|
|
Loading…
Reference in New Issue