mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Allow SIGINT in non-interactive mode
Prior to this fix, fish would swallow SIGINT in non-interactive mode. This meant that scripts could only be Ctrl-C'd if fish was executing an external command. Unblock SIGINT in non-interactive mode. Fixes #5253
This commit is contained in:
parent
c76de58758
commit
f212518d3e
1 changed files with 11 additions and 3 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "common.h"
|
||||
#include "event.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include "parser.h"
|
||||
#include "proc.h"
|
||||
#include "reader.h"
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
@ -233,6 +234,12 @@ static void handle_int(int sig, siginfo_t *info, void *context) {
|
|||
default_handler(sig, info, context);
|
||||
}
|
||||
|
||||
/// Non-interactive ^C handler.
|
||||
static void handle_int_notinteractive(int sig, siginfo_t *info, void *context) {
|
||||
parser_t::skip_all_blocks();
|
||||
default_handler(sig, info, context);
|
||||
}
|
||||
|
||||
/// sigchld handler. Does notification and calls the handler in proc.c.
|
||||
static void handle_chld(int sig, siginfo_t *info, void *context) {
|
||||
job_handle_signal(sig, info, context);
|
||||
|
@ -317,11 +324,12 @@ static void set_non_interactive_handlers() {
|
|||
act.sa_flags = 0;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
||||
// Non-interactive. Ignore interrupt, check exit status of processes to determine result
|
||||
// instead.
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGINT, &act, 0);
|
||||
sigaction(SIGQUIT, &act, 0);
|
||||
|
||||
act.sa_sigaction = &handle_int_notinteractive;
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
sigaction(SIGINT, &act, NULL);
|
||||
}
|
||||
|
||||
/// Sets up appropriate signal handlers.
|
||||
|
|
Loading…
Reference in a new issue