diff --git a/uiterm/ui.go b/uiterm/ui.go index 7b3d725..c6041b9 100644 --- a/uiterm/ui.go +++ b/uiterm/ui.go @@ -5,6 +5,7 @@ import ( "strings" "sync" "sync/atomic" + "time" "github.com/nsf/termbox-go" ) @@ -142,7 +143,12 @@ func (ui *Ui) Run(cmds chan string) error { }() defer func() { termbox.Close() - <-pollDone + // Some termbox backends do not wake PollEvent promptly on Close. A fatal + // startup failure must print its stderr error instead of hanging here. + select { + case <-pollDone: + case <-time.After(100 * time.Millisecond): + } }() ui.manager.OnUiInitialize(ui)