From 7694d9082153d3ddfc0ca0815731e1a093321ac1 Mon Sep 17 00:00:00 2001 From: Noboru Saito Date: Wed, 24 Feb 2021 22:49:58 +0900 Subject: [PATCH] Change to /dev/tty because term.GetState fails The file descriptor of "os.Stdin" may cause term.GetState to be an error. --- tscreen_unix.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tscreen_unix.go b/tscreen_unix.go index 53fcb9d..725785c 100644 --- a/tscreen_unix.go +++ b/tscreen_unix.go @@ -103,11 +103,14 @@ func (t *tScreen) disengage() { func (t *tScreen) initialize() error { var err error t.out = os.Stdout - t.in = os.Stdin - t.saved, err = term.GetState(int(os.Stdin.Fd())) - if err != nil { + if t.in, err = os.Open("/dev/tty"); err != nil { return err } + + t.saved, err = term.GetState(int(t.in.Fd())) + if err == nil { + return nil + } return nil }