This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Signal handling and SuspendThread


On Fri, Dec 16, 2005 at 02:42:11PM -0800, Max Kaehn wrote:
>I spent quite a bit of time puzzling over what could be going wrong;
>eventually, I gave our chief architect the guided tour of the signal
>handling code and he wondered if SuspendThread() might return before
>the suspended thread has halted.  (The MSDN documentation doesn't
>actually specify this one way or the other.)

There seems to be a lot of code out there which relies on GetThreadContext
returning something sane after a SuspendThread, however.

Does the below patch cause any difference in behavior?

cgf

Index: exceptions.cc
===================================================================
RCS file: /cvs/uberbaum/winsup/cygwin/exceptions.cc,v
retrieving revision 1.268
diff -u -p -r1.268 exceptions.cc
--- exceptions.cc	7 Dec 2005 11:16:47 -0000	1.268
+++ exceptions.cc	17 Dec 2005 02:29:26 -0000
@@ -786,17 +786,12 @@ setup_handler (int sig, void *handler, s
 	  ResumeThread (hth);
 	  break;
 	}
-      if (tls->incyg || tls->spinning || tls->locked ())
-	sigproc_printf ("incyg %d, spinning %d, locked %d\n",
-			tls->incyg, tls->spinning, tls->locked ());
-      else
-	{
-	  cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
-	  if (!GetThreadContext (hth, &cx))
-	    system_printf ("couldn't get context of main thread, %E");
-	  else if (interruptible (cx.Eip))
-	    interrupted = tls->interrupt_now (&cx, sig, handler, siga);
-	}
+      cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
+      if (!GetThreadContext (hth, &cx))
+	system_printf ("couldn't get context of main thread, %E");
+      else if (interruptible (cx.Eip) &&
+	       !(tls->incyg || tls->spinning || tls->locked ()))
+	interrupted = tls->interrupt_now (&cx, sig, handler, siga);
 
       res = ResumeThread (hth);
       if (interrupted)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]