Skip to content
Myr

Fix CTRL-Z handling

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

Fix #3802 This fixes `xterm -e fzf` hangs on CTRL-Z * Replace SIGSTOP with SIGTSTP * Do not rely on SIGCONT

authored by Junegunn Choi · committed by Junegunn Choi · parent a09c6e9 · Browse files · 3 files+3 added−25 removed
This commit

State

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

Diff stats

3 files+3 added−25 removed

  • other:+3 added−25 removed

3 files+3 added−25 removed

modified:src/terminal_unix.go+1 added-5 removed
18 unmodified lines
19 pgid, err := unix.Getpgid(pid)20 if err == nil {21 pid = pgid * -122 }23 unix.Kill(pid, syscall.SIGSTOP)23 unix.Kill(pid, syscall.SIGTSTP)24}2526func notifyOnCont(resizeChan chan<- os.Signal) {27 signal.Notify(resizeChan, syscall.SIGCONT)28}
modified:src/terminal_windows.go-4 removed
11 unmodified lines
1213func notifyStop(p *os.Process) {14 // NOOP15}1617func notifyOnCont(resizeChan chan<- os.Signal) {18 // NOOP19}
modified:src/terminal.go+2 added-16 removed
852 unmodified lines
853 eventBox: eventBox,854 mutex: sync.Mutex{},855 uiMutex: sync.Mutex{},856 suppress: true,857 sigstop: false,857 slab: util.MakeSlab(slab16Size, slab32Size),858 theme: opts.Theme,859 startChan: make(chan fitpad, 1),860 killChan: make(chan bool),
2574 unmodified lines
3435 }3436 }3437 }()34383440 contChan := make(chan os.Signal, 1)3441 notifyOnCont(contChan)3442 go func() {3443 for {3444 select {3445 case <-ctx.Done():3446 return3447 case <-contChan:3448 t.reqBox.Set(reqReinit, nil)3449 }3450 }3451 }()34523439 if !t.tui.ShouldEmitResizeEvent() {3440 resizeChan := make(chan os.Signal, 1)3441 notifyOnResize(resizeChan) // Non-portable3442 go func() {
329 unmodified lines
3772 t.printLabel(t.border, t.borderLabel, t.borderLabelOpts, t.borderLabelLen, t.borderShape, true)3773 case reqRedrawPreviewLabel:3774 t.printLabel(t.pborder, t.previewLabel, t.previewLabelOpts, t.previewLabelLen, t.previewOpts.border, true)3775 case reqReinit:3790 t.tui.Resume(t.fullscreen, t.sigstop)3776 t.tui.Resume(t.fullscreen, true)3777 t.fullRedraw()3778 case reqResize, reqFullRedraw:3779 if req == reqResize {3780 t.termSize = t.tui.Size()
731 unmodified lines
4512 req(reqPrompt)4513 case actSigStop:4514 p, err := os.FindProcess(os.Getpid())4515 if err == nil {4530 t.sigstop = true4516 t.tui.Clear()4517 t.tui.Pause(t.fullscreen)4518 notifyStop(p)4519 t.mutex.Unlock()4520 t.reqBox.Set(reqReinit, nil)4521 return false4522 }4523 case actMouse:4524 me := event.MouseEvent
544 unmodified lines