2
0
mirror of https://github.com/junegunn/fzf synced 2024-11-14 18:12:53 +00:00

proxy: Pass SIGINT to the child fzf

This commit is contained in:
Junegunn Choi 2024-05-22 22:14:00 +09:00
parent 6b4358f641
commit 303c3bae7f
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -103,7 +103,14 @@ func runProxy(commandPrefix string, cmdBuilder func(temp string) *exec.Cmd, opts
defer os.Remove(temp) defer os.Remove(temp)
cmd := cmdBuilder(temp) cmd := cmdBuilder(temp)
signal.Ignore(os.Interrupt) intChan := make(chan os.Signal, 1)
defer close(intChan)
go func() {
if sig, valid := <-intChan; valid {
cmd.Process.Signal(sig)
}
}()
signal.Notify(intChan, os.Interrupt)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok { if exitError, ok := err.(*exec.ExitError); ok {
code := exitError.ExitCode() code := exitError.ExitCode()