summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-10-05 23:19:26 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-10-05 23:19:26 +0900
commit86bc9d506fb29d65d6d666d18422f3337bf52f13 (patch)
tree48453e32d7abf216db87036acf31ea4743b63ffb /src
parenteee45a9578042c70353d83267e67b442afa13b4c (diff)
downloadfzf-86bc9d506fb29d65d6d666d18422f3337bf52f13.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/curses/curses.go9
-rw-r--r--src/terminal.go7
2 files changed, 7 insertions, 9 deletions
diff --git a/src/curses/curses.go b/src/curses/curses.go
index debdeaf4..06493a2a 100644
--- a/src/curses/curses.go
+++ b/src/curses/curses.go
@@ -11,7 +11,6 @@ import "C"
import (
"fmt"
"os"
- "os/signal"
"syscall"
"time"
"unicode/utf8"
@@ -271,14 +270,6 @@ func Init(theme *ColorTheme, black bool, mouse bool) {
C.noecho()
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 {
C.start_color()
initPairs(theme, black)
diff --git a/src/terminal.go b/src/terminal.go
index 9a92ba43..ab77ecfe 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -727,6 +727,13 @@ func (t *Terminal) Loop() {
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)
signal.Notify(resizeChan, syscall.SIGWINCH)
go func() {