From 57ba174fa0fd038154f5f24a32cad566796ee2a6 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 28 Dec 2004 01:27:26 +0000 Subject: * cygthread.cc (cygthread::stub): Add better debug output. (cygthread::cygthread): Ditto. (cygthread::terminate_thread): Ditto. Move inuse test earlier or suffer infinite loop. * pinfo.cc (_pinfo::dup_proc_pipe): Close handle if DuplicateHandle fails and process no longer exists. * spawn.cc (spawn_guts): Create process in suspended state if OS demands it. * wincap.cc: Add "start_proc_suspended" throughout. * wincap.h (wincaps): Ditto. (wincapc): Ditto. --- winsup/cygwin/cygthread.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'winsup/cygwin/cygthread.cc') diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index 20f51d593..55022f370 100644 --- a/winsup/cygwin/cygthread.cc +++ b/winsup/cygwin/cygthread.cc @@ -45,6 +45,7 @@ cygthread::stub (VOID *arg) else { info->stack_ptr = &arg; + debug_printf ("thread '%s', id %p, stack_ptr %p", info->name (), info->id, info->stack_ptr); if (!info->ev) { info->ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL); @@ -166,7 +167,7 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param, while (!thread_sync) low_priority_sleep (0); SetEvent (thread_sync); - thread_printf ("activated thread_sync %p", thread_sync); + thread_printf ("activated name '%s', thread_sync %p for thread %p", thread_sync, id); } else { @@ -179,7 +180,7 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param, this, 0, &id); if (!h) api_fatal ("thread handle not set - %p<%p>, %E", h, id); - thread_printf ("created thread %p", h); + thread_printf ("created name '%s', thread %p, id %p", __name, h, id); #ifdef DEBUGGING terminated = false; #endif @@ -268,18 +269,21 @@ cygthread::terminate_thread () ResetEvent (*this); ResetEvent (thread_sync); } + + debug_printf ("thread '%s', id %p, inuse %d, stack_ptr %p", name (), id, inuse, stack_ptr); + while (inuse && !stack_ptr) + low_priority_sleep (0); + if (!inuse) return; + (void) TerminateThread (h, 0); (void) WaitForSingleObject (h, INFINITE); - if (!inuse) + if (!inuse || exiting) return; CloseHandle (h); - while (inuse && !stack_ptr) - low_priority_sleep (0); - if (!inuse) return; -- cgit v1.2.3