2c2fa1
We may abort the process of detaching threads with multiple SIGINTs - which are
2c2fa1
being sent during a testcase terminating its child GDB.
2c2fa1
2c2fa1
Some of the threads may not be properly PTRACE_DETACHed which hurts if they
2c2fa1
should have been detached with SIGSTOP (as they are accidentally left running
2c2fa1
on the debugger termination).
2c2fa1
2c2fa1
Index: gdb-7.5.50.20130118/gdb/defs.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.5.50.20130118.orig/gdb/defs.h	2013-01-01 07:32:41.000000000 +0100
2c2fa1
+++ gdb-7.5.50.20130118/gdb/defs.h	2013-01-21 16:40:29.889256633 +0100
2c2fa1
@@ -176,6 +176,7 @@ extern int check_quit_flag (void);
2c2fa1
 /* Set the quit flag.  */
2c2fa1
 extern void set_quit_flag (void);
2c2fa1
 
2c2fa1
+extern int quit_flag_cleanup;
2c2fa1
 extern int immediate_quit;
2c2fa1
 
2c2fa1
 extern void quit (void);
2c2fa1
Index: gdb-7.5.50.20130118/gdb/top.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.5.50.20130118.orig/gdb/top.c	2013-01-21 14:56:12.000000000 +0100
2c2fa1
+++ gdb-7.5.50.20130118/gdb/top.c	2013-01-21 14:56:16.385710056 +0100
2c2fa1
@@ -1329,7 +1329,9 @@ quit_force (char *args, int from_tty)
2c2fa1
   qt.args = args;
2c2fa1
   qt.from_tty = from_tty;
2c2fa1
 
2c2fa1
-  /* We want to handle any quit errors and exit regardless.  */
2c2fa1
+  /* We want to handle any quit errors and exit regardless but we should never
2c2fa1
+     get user-interrupted to properly detach the inferior.  */
2c2fa1
+  quit_flag_cleanup = 1;
2c2fa1
   catch_errors (quit_target, &qt,
2c2fa1
 	        "Quitting: ", RETURN_MASK_ALL);
2c2fa1
 
2c2fa1
Index: gdb-7.5.50.20130118/gdb/utils.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.5.50.20130118.orig/gdb/utils.c	2013-01-21 14:56:12.000000000 +0100
2c2fa1
+++ gdb-7.5.50.20130118/gdb/utils.c	2013-01-21 16:41:02.225233493 +0100
2c2fa1
@@ -141,6 +141,11 @@ int quit_flag;
2c2fa1
 
2c2fa1
 int immediate_quit;
2c2fa1
 
2c2fa1
+/* Nonzero means we are already processing the quitting cleanups and we should
2c2fa1
+   no longer get aborted.  */
2c2fa1
+
2c2fa1
+int quit_flag_cleanup;
2c2fa1
+
2c2fa1
 #ifndef HAVE_PYTHON
2c2fa1
 
2c2fa1
 /* Clear the quit flag.  */
2c2fa1
@@ -164,6 +169,9 @@ set_quit_flag (void)
2c2fa1
 int
2c2fa1
 check_quit_flag (void)
2c2fa1
 {
2c2fa1
+  if (quit_flag_cleanup)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
   /* This is written in a particular way to avoid races.  */
2c2fa1
   if (quit_flag)
2c2fa1
     {
2c2fa1
Index: gdb-7.5.50.20130118/gdb/python/python.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.5.50.20130118.orig/gdb/python/python.c	2013-01-21 16:39:03.000000000 +0100
2c2fa1
+++ gdb-7.5.50.20130118/gdb/python/python.c	2013-01-21 16:39:30.698299142 +0100
2c2fa1
@@ -181,6 +181,9 @@ set_quit_flag (void)
2c2fa1
 int
2c2fa1
 check_quit_flag (void)
2c2fa1
 {
2c2fa1
+  if (quit_flag_cleanup)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
   return PyOS_InterruptOccurred ();
2c2fa1
 }
2c2fa1