diff --git a/tscreen.go b/tscreen.go index ebd61a2..a0820a4 100644 --- a/tscreen.go +++ b/tscreen.go @@ -1547,7 +1547,12 @@ func (t *tScreen) inputLoop(stopQ chan struct{}) { switch e { case nil: default: - _ = t.PostEvent(NewEventError(e)) + t.Lock() + running := t.running + t.Unlock() + if running { + _ = t.PostEvent(NewEventError(e)) + } return } if n > 0 { diff --git a/tty_unix.go b/tty_unix.go index 0c6ea78..dbd961b 100644 --- a/tty_unix.go +++ b/tty_unix.go @@ -72,7 +72,7 @@ func (tty *devTty) Start() error { if tty.f, err = os.OpenFile(tty.dev, os.O_RDWR, 0); err != nil { return err } - tty.fd = int(tty.of.Fd()) + tty.fd = int(tty.f.Fd()) if !term.IsTerminal(tty.fd) { return errors.New("device is not a terminal")