diff --git a/NEWS.adoc b/NEWS.adoc index 9096b8a41..012edeedd 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -12,6 +12,7 @@ Bug fixes: - Fix reopening the blame view from the main view. - Fix editing when stdin is redirected. (#1330) - Fix compilation warnings with ncurses 6.5. + - Make `Ctrl-C` to kill only the command running in the foreground. (#1331) tig-2.5.9 --------- diff --git a/src/display.c b/src/display.c index 5152576df..c0322a501 100644 --- a/src/display.c +++ b/src/display.c @@ -84,6 +84,7 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf ok = io_run_bg(argv, dir); } else { + signal(SIGINT, SIG_IGN); clear(); refresh(); endwin(); /* restore original tty modes */ @@ -101,6 +102,7 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf fseek(opt_tty.file, 0, SEEK_END); tcsetattr(opt_tty.fd, TCSAFLUSH, opt_tty.attr); set_terminal_modes(); + signal(SIGINT, SIG_DFL); } if (watch_update(WATCH_EVENT_AFTER_COMMAND) && do_refresh) { diff --git a/src/io.c b/src/io.c index 26ad1c512..4eb7c85a7 100644 --- a/src/io.c +++ b/src/io.c @@ -436,6 +436,13 @@ io_exec(struct io *io, enum io_type type, const char *dir, char * const env[], c putenv(env[i]); } + signal(SIGHUP, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGPIPE, SIG_DFL); +#ifdef DEBUG + signal(SIGSEGV, SIG_DFL); +#endif + execvp(argv[0], (char *const*) argv); close(STDOUT_FILENO);