if using readline , the CTRL-C should now handle it a bit more nicer. Especially the pm3 history file should be flushed with the upside you dont loose all your commands you issued and mistakingly pressed CTRL-C. for the linenoice and Win32, you still have this issue.

This commit is contained in:
iceman1001
2024-04-06 20:57:54 +02:00
parent 7c755e20bc
commit a68a5a8825
2 changed files with 17 additions and 3 deletions
+16 -3
View File
@@ -123,10 +123,20 @@ static bool WINAPI terminate_handler(DWORD t) {
# else
static struct sigaction gs_old_sigint_action;
static void sigint_handler(int signum) {
sigaction(SIGINT, &gs_old_sigint_action, NULL);
pm3line_flush_history();
kill(0, SIGINT);
switch(signum) {
case SIGINT: {
sigaction(SIGINT, &gs_old_sigint_action, NULL);
pm3line_flush_history();
kill(0, SIGINT);
break;
}
default: {
break;
}
}
}
#endif
void pm3line_install_signals(void) {
@@ -138,6 +148,7 @@ void pm3line_install_signals(void) {
action.sa_handler = &sigint_handler;
sigaction(SIGINT, &action, &gs_old_sigint_action);
# endif
#if defined(HAVE_READLINE)
rl_catch_signals = 1;
rl_set_signals();
@@ -150,6 +161,8 @@ void pm3line_init(void) {
using_history();
rl_readline_name = "PM3";
rl_attempted_completion_function = rl_command_completion;
rl_getc_function = getc;
pm3line_install_signals();
#ifdef RL_STATE_READCMD
rl_extend_line_buffer(1024);