Semi-reversion of always-exit-from-sigthread change of 2005-09-15.

* exceptions.cc (sigpacket::process): Eliminate return after call to reinstated
noreturn function.
(signal_exit): Allow function to exit when a captive process has been
terminated.
* pinfo.cc (pinfo::exit): Enter exit_lock here.  Once again exit here under
control of exit_lock.
* sigproc.cc (sig_send): Don't wait for completion if process is exiting.
Remove special __SIGEXIT accommodations.
(wait_sig): Just exit the thread when a __SIGEXIT has been detected.  Don't
exit the process.
This commit is contained in:
Christopher Faylor
2005-09-23 23:37:52 +00:00
parent 1b19d74296
commit 5e477e9a9b
5 changed files with 26 additions and 57 deletions

View File

@@ -553,7 +553,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
}
if (wait_sig_inited)
wait_for_sigthread ();
wait_for_completion = p != myself_nowait && _my_tls.isinitialized ();
wait_for_completion = p != myself_nowait && _my_tls.isinitialized () && !exit_state;
p = myself;
}
@@ -621,15 +621,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
pack.si.si_uid = myself->uid;
pack.pid = myself->pid;
pack.tls = (_cygtls *) tls;
if (si.si_signo == __SIGEXIT)
{
if (&_my_tls == _main_tls)
pack.thread_handle = hMainThread;
else
DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc, &pack.thread_handle, 0,
FALSE, DUPLICATE_SAME_ACCESS);
}
else if (wait_for_completion)
if (wait_for_completion)
{
pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
sigproc_printf ("wakeup %p", pack.wakeup);
@@ -1122,29 +1114,6 @@ wait_sig (VOID *self)
break;
}
my_sendsig = NULL;
HANDLE& h = pack.thread_handle;
if (!h)
api_fatal ("no thread handle set on exit");
DWORD res = WaitForSingleObject (h, INFINITE);
DWORD exitcode = 1;
myself.release ();
if (res == WAIT_OBJECT_0)
{
GetExitCodeThread (h, &exitcode);
#ifdef DEBUGGING
hMainThread = INVALID_HANDLE_VALUE;
#endif
} else {
#ifdef DEBUGGING
console_printf ("wait for main thread %p returned %d", h, res);
#else
debug_printf ("wait for main thread %p returned %d", h, res);
#endif
}
sigproc_printf ("calling ExitProcess, exitcode %p", exitcode);
ExitProcess (exitcode);
sigproc_printf ("signal thread exiting");
ExitThread (0);
}