chg: disable ctrl-c on mingw/ps
This commit is contained in:
@@ -146,6 +146,18 @@ static void flush_history(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_READLINE
|
#ifdef HAVE_READLINE
|
||||||
|
|
||||||
|
# if defined(_WIN32)
|
||||||
|
/*
|
||||||
|
static bool WINAPI terminate_handler(DWORD t) {
|
||||||
|
if (t == CTRL_C_EVENT) {
|
||||||
|
flush_history();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
# else
|
||||||
struct sigaction old_action;
|
struct sigaction old_action;
|
||||||
static void terminate_handler(int signum) {
|
static void terminate_handler(int signum) {
|
||||||
sigaction(SIGINT, &old_action, NULL);
|
sigaction(SIGINT, &old_action, NULL);
|
||||||
@@ -154,6 +166,8 @@ static void terminate_handler(int signum) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// first slot is always NULL, indicating absence of script when idx=0
|
// first slot is always NULL, indicating absence of script when idx=0
|
||||||
static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0};
|
static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0};
|
||||||
static uint8_t cmdscriptfile_idx = 0;
|
static uint8_t cmdscriptfile_idx = 0;
|
||||||
@@ -236,11 +250,14 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
|||||||
session.history_path = NULL;
|
session.history_path = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
# if defined(_WIN32)
|
||||||
|
// SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true);
|
||||||
|
# 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 = &terminate_handler;
|
||||||
sigaction(SIGINT, &action, &old_action);
|
sigaction(SIGINT, &action, &old_action);
|
||||||
|
# endif
|
||||||
rl_catch_signals = 1;
|
rl_catch_signals = 1;
|
||||||
rl_set_signals();
|
rl_set_signals();
|
||||||
read_history(session.history_path);
|
read_history(session.history_path);
|
||||||
@@ -1054,7 +1071,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
#ifdef HAVE_GUI
|
#ifdef HAVE_GUI
|
||||||
|
|
||||||
# ifdef _WIN32
|
# if defined(_WIN32)
|
||||||
InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop);
|
InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop);
|
||||||
MainGraphics();
|
MainGraphics();
|
||||||
# else
|
# else
|
||||||
|
|||||||
Reference in New Issue
Block a user