* exceptions.cc (sigtid): Remove declaration.

(handle_exceptions): Use _sig_tls rather than sigtid to determine if this is
the signal thread.
(set_signal_mask): Ditto for conditionalized CGF code.
* pinfo.cc (pinfo::exit): Exit the thread if we forcefully terminated the main
thread
* sigproc.cc (sigtid): Delete.
(_sig_tls): Define.
(sig_clear): Use _sig_tls rather than sigtid to determine if this is the signal
thread.
(sig_dispatch_pending): Ditto.
(wait_sig): Set _sig_tls here.
* dcrt0.cc (do_exit): Move sigproc_terminate call later since signal handling
was still needed for subsequent stuff.  Call sigproc_terminate with new
exit_state value.
* pinfo.cc (pinfo::exit): Call sigproc_terminate with new exit_state value.
* sigproc.cc (proc_terminate): Remove unnecessary (void) parameter.
(sigproc_terminate): Ditto.  Add new argument to accept exit state to be set.
(wait_sig): Reorganize __SIGEXIT handling.  Add more debugging output.
* winsup.h (sigproc_terminate): Declare with new exit_state argument.
(exit_states): Reorganize to reflect new exit ordering of sigproc_terminate.
This commit is contained in:
Christopher Faylor
2005-09-14 14:00:07 +00:00
parent 67483cb2cd
commit a611ae50d5
8 changed files with 79 additions and 42 deletions

View File

@@ -136,8 +136,7 @@ pinfo::zap_cwd ()
void
pinfo::exit (DWORD n)
{
sigproc_terminate ();
exit_state = ES_FINAL;
sigproc_terminate (ES_FINAL);
cygthread::terminate ();
if (n != EXITCODE_NOSET)
@@ -165,20 +164,25 @@ pinfo::exit (DWORD n)
_my_tls.stackptr = _my_tls.stack;
if (&_my_tls == _main_tls)
{
sigproc_printf ("Calling ExitProcess hProcess %p, n %p, exitcode %p",
sigproc_printf ("Calling ExitThread hProcess %p, n %p, exitcode %p",
hProcess, n, exitcode);
ExitThread (exitcode);
}
else if (hMainThread)
{
#if 0 /* This would be nice, but I don't think that Windows guarantees that
TerminateThread will not block. */
sigproc_printf ("Calling TerminateThread since %p != %p, %p, n %p, exitcode %p",
&_my_tls, _main_tls, hProcess, n, exitcode);
TerminateThread (hMainThread, exitcode);
if (&_my_tls != _sig_tls)
ExitThread (0);
#endif
}
sigproc_printf ("Calling ExitProcess since hMainthread is 0, hProcess %p, n %p, exitcode %p",
hProcess, n, exitcode);
release ();
// release (); Could race with signal thread. Sigh.
ExitProcess (exitcode);
}
# undef self