summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2021-03-07 21:43:24 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2021-03-07 21:44:08 +0900
commitf657169616a643db9b810d87984146faa2df3d2b (patch)
tree933defe502cbace80ec86138a56be8625011e0e8 /src
parent4c06da8b70d449e8c06d6bc33e8838784553eec3 (diff)
Fix deadlock on exit
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/terminal.go b/src/terminal.go
index aac43ceb..b9d648df 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -133,6 +133,7 @@ type Terminal struct {
count int
progress int
reading bool
+ running bool
failed *string
jumping jumpMode
jumpLabels string
@@ -505,6 +506,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
ansi: opts.Ansi,
tabstop: opts.Tabstop,
reading: true,
+ running: true,
failed: nil,
jumping: jumpDisabled,
jumpLabels: opts.JumpLabels,
@@ -1843,6 +1845,8 @@ func (t *Terminal) exit(getCode func() int) {
}
// prof.Stop()
t.killPreview(code)
+ t.running = false
+ t.mutex.Unlock()
}
// Loop is called to start Terminal I/O
@@ -2068,10 +2072,16 @@ func (t *Terminal) Loop() {
go func() {
var focusedIndex int32 = minItem.Index()
var version int64 = -1
- for {
+ running := true
+ for running {
t.reqBox.Wait(func(events *util.Events) {
defer events.Clear()
t.mutex.Lock()
+ if !t.running {
+ running = false
+ t.mutex.Unlock()
+ return
+ }
for req, value := range *events {
switch req {
case reqPrompt: