5677fb2
We may abort the process of detaching threads with multiple SIGINTs - which are
5677fb2
being sent during a testcase terminating its child GDB.
5677fb2
5677fb2
Some of the threads may not be properly PTRACE_DETACHed which hurts if they
5677fb2
should have been detached with SIGSTOP (as they are accidentally left running
5677fb2
on the debugger termination).
5677fb2
7306e88
Index: gdb-7.11.50.20160630/gdb/defs.h
7306e88
===================================================================
7306e88
--- gdb-7.11.50.20160630.orig/gdb/defs.h	2016-07-03 16:40:43.423078926 +0200
7306e88
+++ gdb-7.11.50.20160630/gdb/defs.h	2016-07-03 16:41:08.568271741 +0200
7306e88
@@ -175,6 +175,10 @@
eb6cb2d
 /* Flag that function quit should call quit_force.  */
eb6cb2d
 extern volatile int sync_quit_force_run;
5677fb2
 
5d17353
+#ifdef NEED_DETACH_SIGSTOP
5677fb2
+extern int quit_flag_cleanup;
5d17353
+#endif
7306e88
+
5677fb2
 extern void quit (void);
7306e88
 
7306e88
 /* Helper for the QUIT macro.  */
7306e88
Index: gdb-7.11.50.20160630/gdb/extension.c
7306e88
===================================================================
7306e88
--- gdb-7.11.50.20160630.orig/gdb/extension.c	2016-07-03 16:40:41.723065890 +0200
7306e88
+++ gdb-7.11.50.20160630/gdb/extension.c	2016-07-03 16:41:44.896550309 +0200
7306e88
@@ -830,6 +830,11 @@
5d17353
   int i, result = 0;
5d17353
   const struct extension_language_defn *extlang;
5d17353
 
5d17353
+#ifdef NEED_DETACH_SIGSTOP
5d17353
+  if (quit_flag_cleanup)
5d17353
+    return 0;
5d17353
+#endif
7306e88
+
5d17353
   ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
5d17353
     {
5d17353
       if (extlang->ops->check_quit_flag != NULL)
7306e88
Index: gdb-7.11.50.20160630/gdb/top.c
7306e88
===================================================================
7306e88
--- gdb-7.11.50.20160630.orig/gdb/top.c	2016-07-03 16:40:41.724065898 +0200
7306e88
+++ gdb-7.11.50.20160630/gdb/top.c	2016-07-03 16:40:43.424078934 +0200
7306e88
@@ -1617,7 +1617,13 @@
32f92b2
   qt.args = args;
32f92b2
   qt.from_tty = from_tty;
5677fb2
 
5d17353
+#ifndef NEED_DETACH_SIGSTOP
5d17353
   /* We want to handle any quit errors and exit regardless.  */
5d17353
+#else
5677fb2
+  /* We want to handle any quit errors and exit regardless but we should never
5677fb2
+     get user-interrupted to properly detach the inferior.  */
5677fb2
+  quit_flag_cleanup = 1;
5d17353
+#endif
5677fb2
 
872aab0
   /* Get out of tfind mode, and kill or detach all inferiors.  */
32f92b2
   TRY
7306e88
Index: gdb-7.11.50.20160630/gdb/utils.c
7306e88
===================================================================
7306e88
--- gdb-7.11.50.20160630.orig/gdb/utils.c	2016-07-03 16:40:41.725065905 +0200
7306e88
+++ gdb-7.11.50.20160630/gdb/utils.c	2016-07-03 16:41:38.961504799 +0200
7306e88
@@ -109,6 +109,13 @@
5677fb2
 
7306e88
 int job_control;
5677fb2
 
5d17353
+#ifdef NEED_DETACH_SIGSTOP
5677fb2
+/* Nonzero means we are already processing the quitting cleanups and we should
5677fb2
+   no longer get aborted.  */
5677fb2
+
5677fb2
+int quit_flag_cleanup;
5d17353
+#endif
7306e88
+
eb6cb2d
 /* Nonzero means that strings with character values >0x7F should be printed
eb6cb2d
    as octal escapes.  Zero means just print the value (e.g. it's an
eb6cb2d
    international character, and the terminal or window can cope.)  */