Skip to content
Myr

Fix preview process not killed on exit

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Thanks to @LangLangBart for the investigation and the suggested fix. Fix #4667

authored by Junegunn Choi · committed by Junegunn Choi · parent 6360c92 · Browse files · 1 file+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−1 removed

  • other:+5 added−1 removed

1 file+5 added−1 removed

modified:src/terminal.go+5 added-1 removed
409 unmodified lines
410 prevLines []itemLine411 suppress bool412 startChan chan fitpad413 killChan chan bool414 killedChan chan bool415 serverInputChan chan []*action416 callbackChan chan versionedCallback417 bgQueue map[action][]func(bool)418 bgSemaphore chan struct{}
682 unmodified lines
1101 slab: util.MakeSlab(slab16Size, slab32Size),1102 theme: opts.Theme,1103 startChan: make(chan fitpad, 1),1104 killChan: make(chan bool),1105 killedChan: make(chan bool),1106 serverInputChan: make(chan []*action, 100),1107 callbackChan: make(chan versionedCallback, maxBgProcesses),1108 bgQueue: make(map[action][]func(bool)),1109 bgSemaphore: make(chan struct{}, maxBgProcesses),
3922 unmodified lines
50325033func (t *Terminal) killPreview() {5034 select {5035 case t.killChan <- true:5036 <-t.killedChan5037 default:5038 }5039}5040
357 unmodified lines
5398 t.reqBox.Set(reqPreviewDelayed, version)5399 case immediately := <-t.killChan:5400 if immediately {5401 util.KillCommand(cmd)5402 t.killedChan <- true5403 } else {5404 // We can immediately kill a long-running preview program5405 // once we started rendering its partial output5406 delay := previewCancelWait
238 unmodified lines
5645 t.uiMutex.Unlock()5646 })5647 }56485645 t.eventBox.Set(EvtQuit, quitSignal{code, nil})5649 t.running.Set(false)5650 t.killPreview()5651 cancel()5652 t.eventBox.Set(EvtQuit, quitSignal{code, nil})5653 }()56545655 looping := true5656 barrier := make(chan bool)
1785 unmodified lines