medfall

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

commit 047d0ce624225b8f313542379fb762a80d935e65
parent daadb73a124bbe701384f36e4703853f09ced95c
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Nov  8 22:22:14 +0200

Only add signal handlers if GDB isn't already attached

Diffstat:
autogdb.h | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/autogdb.h b/autogdb.h @@ -71,15 +71,6 @@ static void prompt_to_run_gdb( int signal ) { } } -static void install_debug_signal_handlers( bool debug_on_sigint ) { - if( debug_on_sigint ) { - signal( SIGINT, prompt_to_run_gdb ); - } - signal( SIGILL, prompt_to_run_gdb ); - signal( SIGABRT, prompt_to_run_gdb ); - signal( SIGSEGV, prompt_to_run_gdb ); -} - static bool being_debugged() { pid_t parent_pid = getpid(); pid_t child_pid = fork(); @@ -111,4 +102,15 @@ static bool being_debugged() { return WEXITSTATUS( status ) == 1; } +static void install_debug_signal_handlers( bool debug_on_sigint ) { + if( being_debugged() ) return; + + if( debug_on_sigint ) { + signal( SIGINT, prompt_to_run_gdb ); + } + signal( SIGILL, prompt_to_run_gdb ); + signal( SIGABRT, prompt_to_run_gdb ); + signal( SIGSEGV, prompt_to_run_gdb ); +} + #endif // _AUTOGDB_H_