* sigproc.cc (wait_sig): Reorganize exit case so that ExitProcess is always

called, since that is the intent of sending a __SIGEXIT.  Wait forever for main
thread to go away since, presumably, the main thread told us it was going away.
This commit is contained in:
Christopher Faylor 2005-09-15 16:06:18 +00:00
parent c4ec3e76b9
commit a3a9aac72d
2 changed files with 27 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2005-09-15 Christopher Faylor <cgf@timesys.com>
* sigproc.cc (wait_sig): Reorganize exit case so that ExitProcess is
always called, since that is the intent of sending a __SIGEXIT. Wait
forever for main thread to go away since, presumably, the main thread
told us it was going away.
2005-09-14 Christopher Faylor <cgf@timesys.com>
* spawn.cc (av::fixup): Avoid breaking out of the wrong "loop".

View File

@ -1125,19 +1125,27 @@ wait_sig (VOID *self)
break;
}
my_sendsig = NULL;
DWORD res = WaitForSingleObject (hMainThread, 10000);
HANDLE h = hMainThread;
my_sendsig = hMainThread = NULL;
DWORD res = h ? WAIT_OBJECT_0 : WaitForSingleObject (h, INFINITE);
if (res != WAIT_OBJECT_0)
sigproc_printf ("wait for main thread returned %d", res);
else
DWORD exitcode = 1;
myself.release ();
if (res == WAIT_OBJECT_0)
{
DWORD exitcode = 1;
myself.release ();
sigproc_printf ("calling ExitProcess, exitcode %p", exitcode);
GetExitCodeThread (hMainThread, &exitcode);
ExitProcess (exitcode);
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 ("exiting thread");
ExitThread (0);
sigproc_printf ("calling ExitProcess, exitcode %p", exitcode);
ExitProcess (exitcode);
}