Fix invalid interrupt handler during execute action

Interrupt handling during execute action was not serialized and often
caused crash, failed to restore the terminal state.
This commit is contained in:
Junegunn Choi 2015-10-05 23:19:26 +09:00
parent eee45a9578
commit 86bc9d506f
2 changed files with 7 additions and 9 deletions

View File

@ -11,7 +11,6 @@ import "C"
import ( import (
"fmt" "fmt"
"os" "os"
"os/signal"
"syscall" "syscall"
"time" "time"
"unicode/utf8" "unicode/utf8"
@ -271,14 +270,6 @@ func Init(theme *ColorTheme, black bool, mouse bool) {
C.noecho() C.noecho()
C.raw() // stty dsusp undef C.raw() // stty dsusp undef
intChan := make(chan os.Signal, 1)
signal.Notify(intChan, os.Interrupt, os.Kill)
go func() {
<-intChan
Close()
os.Exit(2)
}()
if theme != nil { if theme != nil {
C.start_color() C.start_color()
initPairs(theme, black) initPairs(theme, black)

View File

@ -727,6 +727,13 @@ func (t *Terminal) Loop() {
t.reqBox.Set(reqRefresh, nil) t.reqBox.Set(reqRefresh, nil)
}() }()
intChan := make(chan os.Signal, 1)
signal.Notify(intChan, os.Interrupt, os.Kill)
go func() {
<-intChan
t.reqBox.Set(reqQuit, nil)
}()
resizeChan := make(chan os.Signal, 1) resizeChan := make(chan os.Signal, 1)
signal.Notify(resizeChan, syscall.SIGWINCH) signal.Notify(resizeChan, syscall.SIGWINCH)
go func() { go func() {