On Mon, Dec 07, 2009 at 04:46:00PM +0100, Karsten Otto wrote: >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.
It is a known bug in Cygwin. Currently signals are only delivered to the main thread. That needs to be fixed. I'll try to get to this soon. cgf -- 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