* 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.
This commit is contained in:
Christopher Faylor 2004-12-28 01:27:26 +00:00
parent 432524c162
commit 57ba174fa0
6 changed files with 58 additions and 21 deletions

View File

@ -1,3 +1,17 @@
2004-12-27 Christopher Faylor <cgf@timesys.com>
* 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.
2004-12-27 Christopher Faylor <cgf@timesys.com>
* pinfo.cc (_pinfo::exit): Beef up debugging output.

View File

@ -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;

View File

@ -128,7 +128,7 @@ _pinfo::exit (UINT n, bool norecord)
}
}
sigproc_printf ("Calling ExitProcess norecord %d, n %d, exitcode %d",
sigproc_printf ("Calling ExitProcess norecord %d, n %p, exitcode %p",
norecord, n, exitcode);
_my_tls.stacklock = 0;
_my_tls.stackptr = _my_tls.stack;
@ -768,7 +768,11 @@ _pinfo::dup_proc_pipe (HANDLE hProcess)
0, FALSE,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
if (!res)
sigproc_printf ("DuplicateHandle failed, pid %d, hProcess %p, %E", pid, hProcess);
{
if (WaitForSingleObject (hProcess, 0) == WAIT_OBJECT_0)
CloseHandle (wr_proc_pipe);
sigproc_printf ("DuplicateHandle failed, pid %d, hProcess %p, %E", pid, hProcess);
}
else
{
wr_proc_pipe_owner = dwProcessId;

View File

@ -645,7 +645,8 @@ spawn_guts (const char * prog_arg, const char *const *argv,
after CreateProcess and before copying the datastructures to the child.
So we have to start the child in suspend state, unfortunately, to avoid
a race condition. */
if (mode != _P_OVERLAY || cygheap->fdtab.need_fixup_before ())
if (wincap.start_proc_suspended() || mode != _P_OVERLAY
|| cygheap->fdtab.need_fixup_before ())
flags |= CREATE_SUSPENDED;
const char *runpath = null_app_name ? NULL : (const char *) real_path;

View File

@ -53,7 +53,8 @@ static NO_COPY wincaps wincap_unknown = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true
};
static NO_COPY wincaps wincap_95 = {
@ -98,7 +99,8 @@ static NO_COPY wincaps wincap_95 = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true
};
static NO_COPY wincaps wincap_95osr2 = {
@ -143,7 +145,8 @@ static NO_COPY wincaps wincap_95osr2 = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true
};
static NO_COPY wincaps wincap_98 = {
@ -188,7 +191,8 @@ static NO_COPY wincaps wincap_98 = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true
};
static NO_COPY wincaps wincap_98se = {
@ -233,7 +237,8 @@ static NO_COPY wincaps wincap_98se = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true
};
static NO_COPY wincaps wincap_me = {
@ -278,7 +283,8 @@ static NO_COPY wincaps wincap_me = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true
};
static NO_COPY wincaps wincap_nt3 = {
@ -323,7 +329,8 @@ static NO_COPY wincaps wincap_nt3 = {
has_terminal_services:false,
has_switch_to_thread:false,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false
};
static NO_COPY wincaps wincap_nt4 = {
@ -368,7 +375,8 @@ static NO_COPY wincaps wincap_nt4 = {
has_terminal_services:false,
has_switch_to_thread:true,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false
};
static NO_COPY wincaps wincap_nt4sp4 = {
@ -413,7 +421,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_terminal_services:false,
has_switch_to_thread:true,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false
};
static NO_COPY wincaps wincap_2000 = {
@ -458,7 +467,8 @@ static NO_COPY wincaps wincap_2000 = {
has_terminal_services:true,
has_switch_to_thread:true,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false
};
static NO_COPY wincaps wincap_xp = {
@ -503,7 +513,8 @@ static NO_COPY wincaps wincap_xp = {
has_terminal_services:true,
has_switch_to_thread:true,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:true
has_ioctl_storage_get_media_types_ex:true,
start_proc_suspended:false
};
static NO_COPY wincaps wincap_2003 = {
@ -548,7 +559,8 @@ static NO_COPY wincaps wincap_2003 = {
has_terminal_services:true,
has_switch_to_thread:true,
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:true
has_ioctl_storage_get_media_types_ex:true,
start_proc_suspended:false
};
wincapc wincap;

View File

@ -55,6 +55,7 @@ struct wincaps
unsigned has_switch_to_thread : 1;
unsigned cant_debug_dll_entry : 1;
unsigned has_ioctl_storage_get_media_types_ex : 1;
unsigned start_proc_suspended : 1;
};
class wincapc
@ -114,6 +115,7 @@ public:
bool IMPLEMENT (has_switch_to_thread)
bool IMPLEMENT (cant_debug_dll_entry)
bool IMPLEMENT (has_ioctl_storage_get_media_types_ex)
bool IMPLEMENT (start_proc_suspended)
#undef IMPLEMENT
};