Avoid terminal shutdown hang after fatal startup errors
This commit is contained in:
committed by
Brandon McGinty
parent
6bf79acc6a
commit
3448ed5802
+7
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user