medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 58e90c9730426b75d43c8a0ee38676cb16cb7556
parent 29d41209fc6572caf19a53665e7387584723bc25
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri Oct 21 17:42:26 +0300

Bell in autogdb and allow gdb to continue from SIGINT/SIGTRAP

Diffstat:
autogdb.h | 21+++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/autogdb.h b/autogdb.h @@ -17,24 +17,34 @@ static void pause_forever( int signal ) { } static void uninstall_debug_signal_handlers() { - signal( SIGINT, SIG_DFL ); + signal( SIGINT, SIG_IGN ); signal( SIGILL, pause_forever ); + signal( SIGTRAP, SIG_IGN ); signal( SIGABRT, pause_forever ); signal( SIGSEGV, pause_forever ); } +static void reset_debug_signal_handlers() { + signal( SIGINT, SIG_DFL ); + signal( SIGILL, SIG_DFL ); + signal( SIGTRAP, SIG_DFL ); + signal( SIGABRT, SIG_DFL ); + signal( SIGSEGV, SIG_DFL ); +} + static void prompt_to_run_gdb( int signal ) { uninstall_debug_signal_handlers(); const char * signal_names[ NSIG ]; signal_names[ SIGINT ] = "SIGINT"; signal_names[ SIGILL ] = "SIGILL"; + signal_names[ SIGTRAP ] = "SIGTRAP"; signal_names[ SIGABRT ] = "SIGABRT"; signal_names[ SIGSEGV ] = "SIGSEGV"; char crashed_pid[ 16 ]; snprintf( crashed_pid, sizeof( crashed_pid ), "%d", getpid() ); - printf( "PID %s received %s. Debug? (y/n)\n", crashed_pid, signal_names[ signal ] ); + printf( "\nPID %s received %s. Debug? (y/n)\n", crashed_pid, signal_names[ signal ] ); char buf[ 2 ]; read( STDIN_FILENO, &buf, sizeof( buf ) ); @@ -47,6 +57,7 @@ static void prompt_to_run_gdb( int signal ) { if( child_pid == -1 ) { err( 1, "fork" ); } + reset_debug_signal_handlers(); if( child_pid == 0 ) { execlp( "gdbx", "gdbx", "--", "-q", "-p", crashed_pid, ( char * ) 0 ); @@ -54,8 +65,10 @@ static void prompt_to_run_gdb( int signal ) { err( 1, "execlp" ); } - waitpid( child_pid, NULL, 0 ); - exit( 1 ); + if( signal != SIGINT && signal != SIGTRAP ) { + waitpid( child_pid, NULL, 0 ); + exit( 1 ); + } } static void install_debug_signal_handlers( bool debug_on_sigint ) {