Revert "Latch signal handlers"

This reverts commit 7ed1022cf4.

Fixes #5962.
This commit is contained in:
Fabian Homborg 2019-06-25 11:16:48 +02:00
parent 3bc392a6b3
commit caedf01c00
5 changed files with 9 additions and 20 deletions

View File

@ -1014,7 +1014,7 @@ static void test_cancellation() {
// Enable fish's signal handling here. We need to make this interactive for fish to install its // Enable fish's signal handling here. We need to make this interactive for fish to install its
// signal handlers. // signal handlers.
proc_push_interactive(1); proc_push_interactive(1);
signal_set_handlers(true); signal_set_handlers();
// This tests that we can correctly ctrl-C out of certain loop constructs, and that nothing gets // This tests that we can correctly ctrl-C out of certain loop constructs, and that nothing gets
// printed if we do. // printed if we do.

View File

@ -955,15 +955,18 @@ void proc_sanity_check(const parser_t &parser) {
void proc_push_interactive(int value) { void proc_push_interactive(int value) {
ASSERT_IS_MAIN_THREAD(); ASSERT_IS_MAIN_THREAD();
int old = is_interactive;
interactive_stack.push_back(is_interactive); interactive_stack.push_back(is_interactive);
is_interactive = value; is_interactive = value;
signal_set_handlers_once(is_interactive); if (old != value) signal_set_handlers();
} }
void proc_pop_interactive() { void proc_pop_interactive() {
ASSERT_IS_MAIN_THREAD(); ASSERT_IS_MAIN_THREAD();
int old = is_interactive;
is_interactive = interactive_stack.back(); is_interactive = interactive_stack.back();
interactive_stack.pop_back(); interactive_stack.pop_back();
if (is_interactive != old) signal_set_handlers();
} }
void proc_wait_any(parser_t &parser) { void proc_wait_any(parser_t &parser) {

View File

@ -1744,7 +1744,7 @@ static void reader_interactive_init() {
} }
} }
signal_set_handlers(shell_is_interactive()); signal_set_handlers();
} }
// It shouldn't be necessary to place fish in its own process group and force control // It shouldn't be necessary to place fish in its own process group and force control

View File

@ -325,7 +325,7 @@ static void set_interactive_handlers() {
} }
/// Sets up appropriate signal handlers. /// Sets up appropriate signal handlers.
void signal_set_handlers(bool interactive) { void signal_set_handlers() {
struct sigaction act; struct sigaction act;
act.sa_flags = 0; act.sa_flags = 0;
sigemptyset(&act.sa_mask); sigemptyset(&act.sa_mask);
@ -354,19 +354,11 @@ void signal_set_handlers(bool interactive) {
FATAL_EXIT(); FATAL_EXIT();
} }
if (interactive) { if (shell_is_interactive()) {
set_interactive_handlers(); set_interactive_handlers();
} }
} }
void signal_set_handlers_once(bool interactive) {
static std::once_flag s_noninter_once;
std::call_once(s_noninter_once, signal_set_handlers, false);
static std::once_flag s_inter_once;
if (interactive) std::call_once(s_inter_once, set_interactive_handlers);
}
void signal_handle(int sig, int do_handle) { void signal_handle(int sig, int do_handle) {
struct sigaction act; struct sigaction act;

View File

@ -17,13 +17,7 @@ const wchar_t *signal_get_desc(int sig);
void signal_reset_handlers(); void signal_reset_handlers();
/// Set signal handlers to fish default handlers. /// Set signal handlers to fish default handlers.
/// If \p interactive is set, apply interactive handlers as well. void signal_set_handlers();
/// Note interactive handlers, once applied, are not cleared; they are a strict superset of
/// non-interactive handlers.
void signal_set_handlers(bool interactive);
/// Latch function. This sets signal handlers, but only the first time it is called.
void signal_set_handlers_once(bool interactive);
/// Tell fish what to do on the specified signal. /// Tell fish what to do on the specified signal.
/// ///