From f057f0a857a1b3ac3e4fff8c6cfe8126f8387cd1 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 4 Sep 2021 17:28:22 -0700 Subject: [PATCH] fixes #480 EventError fired after suspended Screen resumes (#484) --- tscreen.go | 7 ++++++- tty_unix.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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")