delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/12/22/19:53:32

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Tue, 22 Dec 2009 19:53:12 -0500
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: 1.7.0: question about signal delivery to pthreads
Message-ID: <20091223005312.GA9233@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4B1D2338 DOT 2050509 AT cell-active DOT com>
MIME-Version: 1.0
In-Reply-To: <4B1D2338.2050509@cell-active.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019