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"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/nsf/termbox-go"
|
"github.com/nsf/termbox-go"
|
||||||
)
|
)
|
||||||
@@ -142,7 +143,12 @@ func (ui *Ui) Run(cmds chan string) error {
|
|||||||
}()
|
}()
|
||||||
defer func() {
|
defer func() {
|
||||||
termbox.Close()
|
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)
|
ui.manager.OnUiInitialize(ui)
|
||||||
|
|||||||
Reference in New Issue
Block a user