With FreeBSD 8.0 it seems like you can't block pending but undelivered signals

Jeremy Allison jra at samba.org
Wed Jan 9 09:59:08 MST 2013


On Wed, Jan 09, 2013 at 06:28:20AM -0800, Richard Sharpe wrote:

> Sure, but the bug is in tevent, not really in the code using it. That
> is, tevent is doing something that is non-portable and possibly broken
> with respect to signals there.
> 
> Here is some text from David Xu on the FreeBSD-hackers mailing list on
> this subject which suggests that the current implementation in
> tevent_signal is wrong.
> 
> -------------------------------------------------
> The way I introduced is standard:
> http://pubs.opengroup.org/onlinepubs/007904975/functions/sigaction.html

W00t! That's what I was hoping for !!!

Ok, if this is a standard mechanism then we have a hope
of fixing it portably.

> I quoted some text here:
> 
> When a signal is caught by a signal-catching function installed by
> sigaction(), a new signal mask is calculated and installed for the
> duration of the signal-catching function (or until a call to either
> sigprocmask() or sigsuspend() is made). This mask is formed by taking
> the union of the current signal mask and the value of the sa_mask for
> the signal being delivered [XSI] [Option Start]  unless SA_NODEFER or
> SA_RESETHAND is set, [Option End] and then including the signal being
> delivered. If and when the user's signal handler returns normally, the
> original signal mask is restored.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Yeah. I *knew* that :-(. What really bugs me is how I forgot
it when looking at the tevent code. We've been bitten by this
before I remember :-(.

> When the signal handler returns, the receiving thread resumes
> execution at the point it was interrupted unless the signal handler
> makes other arrangements. If longjmp() or _longjmp() is used to leave
> the signal handler, then the signal mask must be explicitly restored.
> 
> This volume of IEEE Std 1003.1-2001 defines the third argument of a
> signal handling function when SA_SIGINFO is set as a void * instead of
> a ucontext_t *, but without requiring type checking. New applications
> should explicitly cast the third argument of the signal handling
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> function to ucontext_t *.
> ^^^^^^^^^^^^^^^^^^^^^^^^^

Cool ! Let's work on getting a portable tested fix into tevent !

Jeremy.


More information about the samba-technical mailing list