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