This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: difficult SIGCHLD / pipe hang
- From: Joe Buehler <jbuehler at hekimian dot com>
- To: Cygwin Developers <cygwin-developers at cygwin dot com>
- Date: Mon, 31 Mar 2003 15:41:08 -0500
- Subject: Re: difficult SIGCHLD / pipe hang
- Organization: Spirent Communications, Inc.
- References: <3E88A073.5010003@hekimian.com>
- Reply-to: jbuehler at hekimian dot com
Is there a bug in the following code in exceptions.cc? The code can get the winapi_lock
but break out of the loop before releasing it:
if (!mainthread.get_winapi_lock (1))
continue;
hth = myself->getthread2signal ();
th = NULL;
/* Suspend the thread which will receive the signal. But first ensure that
this thread doesn't have any mutos. (FIXME: Someday we should just grab
all of the mutos rather than checking for them)
For Windows 95, we also have to ensure that the addresses returned by GetThreadContext
are valid.
If one of these conditions is not true we loop for a fixed number of times
since we don't want to stall the signal handler. FIXME: Will this result in
noticeable delays?
If the thread is already suspended (which can occur when a program has called
SuspendThread on itself then just queue the signal. */
EnterCriticalSection (&mainthread.lock);
sigproc_printf ("suspending mainthread");
res = SuspendThread (hth);
/* Just release the lock now since we hav suspended the main thread and it
definitely can't be grabbing it now. This will have to change, of course,
if/when we can send signals to other than the main thread. */
LeaveCriticalSection (&mainthread.lock);
/* Just set pending if thread is already suspended */
if (res)
{
(void) ResumeThread (hth);
break;
}
mainthread.release_winapi_lock ();
Also, with regards to the "break", is it safe to resume the thread before setting
the pending flag?
--
Joe Buehler