From 01188f49f4fc41b86d9dc4ec4a8374433355c50d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 3 Sep 2021 21:45:50 -0700 Subject: [PATCH] fixes #480 EventError fired after suspended Screen resumes --- tscreen.go | 7 ++++++- tty_unix.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tscreen.go b/tscreen.go index ebd61a25..a0820a42 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 0c6ea784..dbd961bb 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")