1.7.0: question about signal delivery to pthreads
Karsten Otto
karsten.otto@cell-active.com
Mon Dec 7 15:46:00 GMT 2009
Hi everybody!
I have a question regarding the delivery of signals to pthreads in
Cygwin (1.7 beta). As an example, please consider the following
situation (see attached file for source code):
There are two threads, a main thread and another one created by the main
thread.
The main registers a SIGALRM signal handler (sigaction), creates the
other thread (pthread_create), blocks all signals (pthread_sigmask),
then waits for a SIGHUP (sigwait) before joining the other thread
(pthread_join).
The other thread unblocks all signals (pthread_sigmask), then schedules
an alarm (alarm(1)) and goes to sleep (sleep(5)).
In this situation, I had expected the other thread to receive the
SIGALRM, and to wake up from sleep consequently; at least it did in
Linux (2.6.31). However, in Cygwin the signal never arrives, the thread
sleeps the full turn.
It seems the signal gets delivered to the blocked main thread instead,
but attempting to check (sigpending) results in a segmentation fault
(SEGV) for some reason.
If I explictly remove the SIGALRM from the block mask, the signal
handler gets called and sigpending works, but of course this interrupts
sigwait (errno=EINTR), hence this is not a viable workaround for me.
So, is cygwin behaving correctly here (in a POSIX sense), or is this a
bug? Please help me understand.
Thank you,
Karsten Otto
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20091207/30c970b8/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sigthread.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20091207/30c970b8/attachment.c>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list