reduce old_action scope to static global, rename for clarity

This commit is contained in:
Philippe Teuwen 2021-08-21 16:11:00 +02:00
commit 45d4d361e9

View file

@ -161,9 +161,9 @@ static bool WINAPI terminate_handler(DWORD t) {
} }
*/ */
# else # else
struct sigaction old_action; static struct sigaction gs_old_sigint_action;
static void terminate_handler(int signum) { static void sigint_handler(int signum) {
sigaction(SIGINT, &old_action, NULL); sigaction(SIGINT, &gs_old_sigint_action, NULL);
flush_history(); flush_history();
kill(0, SIGINT); kill(0, SIGINT);
} }
@ -286,8 +286,8 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
# else # else
struct sigaction action; struct sigaction action;
memset(&action, 0, sizeof(action)); memset(&action, 0, sizeof(action));
action.sa_handler = &terminate_handler; action.sa_handler = &sigint_handler;
sigaction(SIGINT, &action, &old_action); sigaction(SIGINT, &action, &gs_old_sigint_action);
# endif # endif
rl_catch_signals = 1; rl_catch_signals = 1;
rl_set_signals(); rl_set_signals();