diff options
author | Christopher Faylor <me@cgf.cx> | 2012-08-16 17:11:41 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2012-08-16 17:11:41 +0000 |
commit | d01efdbe6ef73e31eca061c031bab84c614a3fe4 (patch) | |
tree | 2d4abf500c907f95c2d118c794c6b7feef78c9f4 /winsup/cygwin/exceptions.cc | |
parent | 4e754267ed8993df41b1ef1abe5e851f54eb5ccc (diff) | |
download | cygnal-d01efdbe6ef73e31eca061c031bab84c614a3fe4.tar.gz cygnal-d01efdbe6ef73e31eca061c031bab84c614a3fe4.tar.bz2 cygnal-d01efdbe6ef73e31eca061c031bab84c614a3fe4.zip |
* cygheap.cc (init_cygheap::find_tls): Don't consider unitialized threads.
* cygtls.cc (_cygtls::operator HANDLE): Return NULL when tid is not set.
* exceptions.cc (setup_handler): Don't try to suspend a thread if it has no
handle.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r-- | winsup/cygwin/exceptions.cc | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 15ef965ac..35b119e9f 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -846,30 +846,34 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _cygtls *tls) DWORD res; HANDLE hth = (HANDLE) *tls; - - /* Suspend the thread which will receive the signal. - If one of these conditions is not true we loop. - If the thread is already suspended (which can occur when a program - has called SuspendThread on itself) then just queue the signal. */ - - sigproc_printf ("suspending thread, tls %p, _main_tls %p", tls, _main_tls); - res = SuspendThread (hth); - /* Just set pending if thread is already suspended */ - if (res) + if (!hth) + sigproc_printf ("thread handle NULL, not set up yet?"); + else { + /* Suspend the thread which will receive the signal. + If one of these conditions is not true we loop. + If the thread is already suspended (which can occur when a program + has called SuspendThread on itself) then just queue the signal. */ + + sigproc_printf ("suspending thread, tls %p, _main_tls %p", tls, _main_tls); + res = SuspendThread (hth); + /* Just set pending if thread is already suspended */ + if (res) + { + ResumeThread (hth); + goto out; + } + cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; + if (!GetThreadContext (hth, &cx)) + sigproc_printf ("couldn't get context of thread, %E"); + else + interrupted = tls->interrupt_now (&cx, sig, handler, siga); + + tls->unlock (); ResumeThread (hth); - goto out; + if (interrupted) + goto out; } - cx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; - if (!GetThreadContext (hth, &cx)) - sigproc_printf ("couldn't get context of thread, %E"); - else - interrupted = tls->interrupt_now (&cx, sig, handler, siga); - - tls->unlock (); - ResumeThread (hth); - if (interrupted) - goto out; sigproc_printf ("couldn't interrupt. trying again."); yield (); |