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
commit a68a5a8825
2 changed files with 17 additions and 3 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased] ## [unreleased][unreleased]
- Changed client now handles CTRL-C and saves history if using READLINE (@iceman1001)
- Changed `hf mf *` - printing of keys if MFC EV1 added extra explaination (@iceman1001) - Changed `hf mf *` - printing of keys if MFC EV1 added extra explaination (@iceman1001)
- Changed `hf mf ginfo - now supports decoding of user supplied configuration block (@iceman1001) - Changed `hf mf ginfo - now supports decoding of user supplied configuration block (@iceman1001)
- Changed `data load` - now shows loaded number as comma printed. (@iceman1001) - Changed `data load` - now shows loaded number as comma printed. (@iceman1001)

View file

@ -123,10 +123,20 @@ static bool WINAPI terminate_handler(DWORD t) {
# else # else
static struct sigaction gs_old_sigint_action; static struct sigaction gs_old_sigint_action;
static void sigint_handler(int signum) { static void sigint_handler(int signum) {
switch(signum) {
case SIGINT: {
sigaction(SIGINT, &gs_old_sigint_action, NULL); sigaction(SIGINT, &gs_old_sigint_action, NULL);
pm3line_flush_history(); pm3line_flush_history();
kill(0, SIGINT); kill(0, SIGINT);
break;
} }
default: {
break;
}
}
}
#endif #endif
void pm3line_install_signals(void) { void pm3line_install_signals(void) {
@ -138,6 +148,7 @@ void pm3line_install_signals(void) {
action.sa_handler = &sigint_handler; action.sa_handler = &sigint_handler;
sigaction(SIGINT, &action, &gs_old_sigint_action); sigaction(SIGINT, &action, &gs_old_sigint_action);
# endif # endif
#if defined(HAVE_READLINE) #if defined(HAVE_READLINE)
rl_catch_signals = 1; rl_catch_signals = 1;
rl_set_signals(); rl_set_signals();
@ -150,6 +161,8 @@ void pm3line_init(void) {
using_history(); using_history();
rl_readline_name = "PM3"; rl_readline_name = "PM3";
rl_attempted_completion_function = rl_command_completion; rl_attempted_completion_function = rl_command_completion;
rl_getc_function = getc;
pm3line_install_signals();
#ifdef RL_STATE_READCMD #ifdef RL_STATE_READCMD
rl_extend_line_buffer(1024); rl_extend_line_buffer(1024);