diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e1536d00f..2ab99a577 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2005-09-15 Christopher Faylor + + * 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 * spawn.cc (av::fixup): Avoid breaking out of the wrong "loop". diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index d8fc2d36c..ede777fb8 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -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); }