diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/cygheap.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 28 | ||||
-rw-r--r-- | winsup/cygwin/signal.cc | 2 |
4 files changed, 29 insertions, 20 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ebac809..5f45854 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +Sun Sep 10 20:23:35 2000 Christopher Faylor <cgf@cygnus.com> + + * cygheap.cc (init_cheap): Just use any old address for the cygwin + heap. + * exceptions.cc (signal_exit): Don't terminate the main thread. Just + try to exit in this thread really quickly. + * signal.cc (kill_pgrp): Fix typo which caused pinfo structure to be + assigned incorrectly. + Sun Sep 10 12:40:49 2000 Christopher Faylor <cgf@cygnus.com> * dcrt0.cc (dll_crt0_1): Initialize thread and debug stuff before diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 09bd680..d8e1333 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -16,13 +16,13 @@ #include "heap.h" #include "cygerrno.h" -#define HEAP_START ((void *) 0x12010000) inline static void init_cheap () { - if (!VirtualAlloc (HEAP_START, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS)) - api_fatal ("Couldn't reserve space for child's heap, %E"); - cygheap = cygheap_max = HEAP_START; + cygheap = VirtualAlloc (NULL, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS); + if (!cygheap) + api_fatal ("Couldn't reserve space for cygwin's heap, %E"); + cygheap_max = cygheap; } #define pagetrunc(x) ((void *) (((DWORD) (x)) & ~(4096 - 1))) @@ -155,7 +155,7 @@ cygheap_fixup_in_child (HANDLE parent) DWORD m, n; n = (DWORD) cygheap_max - (DWORD) cygheap; if (!VirtualAlloc (cygheap, CYGHEAPSIZE, MEM_RESERVE, PAGE_NOACCESS)) - api_fatal ("Couldn't reserve space for child's heap, %E"); + api_fatal ("Couldn't reserve space for cygwin's heap in child, %E"); if (!VirtualAlloc (cygheap, n, MEM_COMMIT, PAGE_READWRITE)) api_fatal ("Couldn't allocate space for child's heap %p, size %d, %E", diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 16b8450..e71c4a7 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -992,11 +992,6 @@ exit_sig: sig |= 0x80; } sigproc_printf ("signal %d, about to call do_exit", sig); - TerminateThread (hMainThread, 0); - /* FIXME: This just works around the problem so that we don't attempt to - use a resource lock when exiting. */ - user_data->resourcelocks->Delete (); - user_data->resourcelocks->Init (); signal_exit (sig); /* Never returns */ } @@ -1007,15 +1002,6 @@ exit_sig: static void signal_exit (int rc) { - /* If the exception handler gets a trap, we could recurse awhile. - If this is non-zero, skip the cleaning up and exit NOW. */ - - muto *m; - /* FIXME: Make multi-thread aware */ - for (m = muto_start.next; m != NULL; m = m->next) - if (m->unstable () || m->owner () == mainthread.id) - m->reset (); - rc = EXIT_SIGNAL | (rc << 8); if (exit_already++) { @@ -1024,6 +1010,20 @@ signal_exit (int rc) ExitProcess (rc); } + /* We'd like to stop the main thread from executing but when we do that it + causes random, inexplicable hangs. So, instead, we set up the priority + of this thread really high so that it should do its thing and then exit. */ + (void) SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); + + /* Unlock any main thread mutos since we're executing with prejudice. */ + muto *m; + for (m = muto_start.next; m != NULL; m = m->next) + if (m->unstable () || m->owner () == mainthread.id) + m->reset (); + + user_data->resourcelocks->Delete (); + user_data->resourcelocks->Init (); + do_exit (rc); } diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index f04adfd..0032201 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -185,7 +185,7 @@ kill_pgrp (pid_t pid, int sig) winpids pids; for (unsigned i = 0; i < pids.npids; i++) { - pinfo p = pids[i]; + pinfo p (pids[i]); if (!proc_exists (p)) continue; |