Avoid terminal shutdown hang after fatal startup errors

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 21:47:24 -04:00
committed by Brandon McGinty
parent 6bf79acc6a
commit 3448ed5802
+7 -1
View File
@@ -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)