We may abort the process of detaching threads with multiple SIGINTs - which are being sent during a testcase terminating its child GDB. Some of the threads may not be properly PTRACE_DETACHed which hurts if they should have been detached with SIGSTOP (as they are accidentally left running on the debugger termination). --- ./gdb/defs.h 26 Jun 2008 15:51:28 -0000 1.227 +++ ./gdb/defs.h 10 Jul 2008 10:37:32 -0000 @@ -141,6 +141,7 @@ extern char *gdb_sysroot; extern char *debug_file_directory; extern int quit_flag; +extern int quit_flag_cleanup; extern int immediate_quit; extern int sevenbit_strings; @@ -159,7 +159,7 @@ extern void quit (void); #define QUIT_FIXME "ignoring redefinition of QUIT" #else #define QUIT { \ - if (quit_flag) quit (); \ + if (quit_flag && !quit_flag_cleanup) quit (); \ if (deprecated_interactive_hook) deprecated_interactive_hook (); \ } #endif --- ./gdb/event-top.c 9 Jul 2008 22:16:14 -0000 1.61 +++ ./gdb/event-top.c 10 Jul 2008 10:37:33 -0000 @@ -941,7 +941,7 @@ async_request_quit (gdb_client_data arg) is no reason to call quit again here, unless immediate_quit is set.*/ - if (quit_flag || immediate_quit) + if ((quit_flag || immediate_quit) && !quit_flag_cleanup) quit (); } --- ./gdb/top.c 9 Jul 2008 22:30:46 -0000 1.145 +++ ./gdb/top.c 10 Jul 2008 10:37:37 -0000 @@ -1263,7 +1263,9 @@ quit_force (char *args, int from_tty) qt.args = args; qt.from_tty = from_tty; - /* We want to handle any quit errors and exit regardless. */ + /* We want to handle any quit errors and exit regardless but we should never + get user-interrupted to properly detach the inferior. */ + quit_flag_cleanup = 1; catch_errors (quit_target, &qt, "Quitting: ", RETURN_MASK_ALL); --- ./gdb/utils.c 10 Jun 2008 09:29:15 -0000 1.189 +++ ./gdb/utils.c 10 Jul 2008 10:37:38 -0000 @@ -120,6 +120,11 @@ int job_control; int quit_flag; +/* Nonzero means we are already processing the quitting cleanups and we should + no longer get aborted. */ + +int quit_flag_cleanup; + /* Nonzero means quit immediately if Control-C is typed now, rather than waiting until QUIT is executed. Be careful in setting this; code which executes with immediate_quit set has to be very careful