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). Index: gdb-7.5.50.20130118/gdb/defs.h =================================================================== --- gdb-7.5.50.20130118.orig/gdb/defs.h 2013-01-01 07:32:41.000000000 +0100 +++ gdb-7.5.50.20130118/gdb/defs.h 2013-01-21 16:40:29.889256633 +0100 @@ -176,6 +176,7 @@ extern int check_quit_flag (void); /* Set the quit flag. */ extern void set_quit_flag (void); +extern int quit_flag_cleanup; extern int immediate_quit; extern void quit (void); Index: gdb-7.5.50.20130118/gdb/top.c =================================================================== --- gdb-7.5.50.20130118.orig/gdb/top.c 2013-01-21 14:56:12.000000000 +0100 +++ gdb-7.5.50.20130118/gdb/top.c 2013-01-21 14:56:16.385710056 +0100 @@ -1329,7 +1329,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); Index: gdb-7.5.50.20130118/gdb/utils.c =================================================================== --- gdb-7.5.50.20130118.orig/gdb/utils.c 2013-01-21 14:56:12.000000000 +0100 +++ gdb-7.5.50.20130118/gdb/utils.c 2013-01-21 16:41:02.225233493 +0100 @@ -141,6 +141,11 @@ int quit_flag; int immediate_quit; +/* Nonzero means we are already processing the quitting cleanups and we should + no longer get aborted. */ + +int quit_flag_cleanup; + #ifndef HAVE_PYTHON /* Clear the quit flag. */ @@ -164,6 +169,9 @@ set_quit_flag (void) int check_quit_flag (void) { + if (quit_flag_cleanup) + return 0; + /* This is written in a particular way to avoid races. */ if (quit_flag) { Index: gdb-7.5.50.20130118/gdb/python/python.c =================================================================== --- gdb-7.5.50.20130118.orig/gdb/python/python.c 2013-01-21 16:39:03.000000000 +0100 +++ gdb-7.5.50.20130118/gdb/python/python.c 2013-01-21 16:39:30.698299142 +0100 @@ -181,6 +181,9 @@ set_quit_flag (void) int check_quit_flag (void) { + if (quit_flag_cleanup) + return 0; + return PyOS_InterruptOccurred (); }