Subject: Re: proposed fix for PR 30348 -- sigwait doesn't get signals from pthread_kill
To: Jaromir Dolecek <jdolecek@NetBSD.org>
From: Chuck Silvers <chuq@chuq.com>
List: tech-userlevel
Date: 10/09/2005 20:25:44
On Sun, Oct 09, 2005 at 10:22:39PM +0200, Jaromir Dolecek wrote:
> On Sun, Oct 09, 2005 at 09:09:12AM -0700, Chuck Silvers wrote:
> > hi,
> > 
> > the attached patch fixes the interactions between sigtimedwait() and
> > pthread_kill().  it allows sigtimedwait() (and its wrappers sigwait()
> > and sigwaitinfo()) to return properly if a signal is received while
> > the thread is sleeping or if a signal is pending already when the
> > function is called.  while I was looking, I noticed another place where
> > we return an error code instead of putting the error code in errno and
> > returning -1, so I fixed that too.
> 
> I believe the check for already pending signals should be done before
> handling the polling (timeout->tv_sec == tv_usec == 0) case. Otherwise
> it might return failure, since pthread_kill() signals are not
> propagated to kernel process state IIRC and thus sigtimedwait() system
> call doesn't know about them.

good point.  I'll make that change.

-Chuck