зеркало из https://github.com/microsoft/docker.git
Change hardcoded "0" onto os.Stdin.Fd()
This commit is contained in:
Родитель
108acc0511
Коммит
6a236184af
|
@ -48,17 +48,17 @@ func daemon() error {
|
|||
func runCommand(args []string) error {
|
||||
var oldState *term.State
|
||||
var err error
|
||||
if term.IsTerminal(0) && os.Getenv("NORAW") == "" {
|
||||
oldState, err = term.MakeRaw(0)
|
||||
if term.IsTerminal(int(os.Stdin.Fd())) && os.Getenv("NORAW") == "" {
|
||||
oldState, err = term.MakeRaw(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer term.Restore(0, oldState)
|
||||
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
for _ = range c {
|
||||
term.Restore(0, oldState)
|
||||
term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
log.Printf("\nSIGINT received\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func runCommand(args []string) error {
|
|||
if err := <-receive_stdout; err != nil {
|
||||
return err
|
||||
}
|
||||
if !term.IsTerminal(0) {
|
||||
if !term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
if err := <-send_stdin; err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func runCommand(args []string) error {
|
|||
}
|
||||
}
|
||||
if oldState != nil {
|
||||
term.Restore(0, oldState)
|
||||
term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче