RE: Threads signalling issue [was RE: threads change]

[email protected] ("Jan Dubois")
Newsgroups perl.perl5.porters,perl.ithreads
Message-ID <01a301c6a7a7$16b92fd0$442b8f70$@com>
On Fri, 14 Jul 2006, Artur Bergman wrote:
> It is threadsafe in the sense you won't crash, but PL_sig_pending
> might be set to 0 by the running thread and thus not cause the
> signal to be delivered until another signal is raised.

Not true, the dispatcher checks the signals *after* resetting the
PL_sig_pending flag:

void
Perl_despatch_signals(pTHX)
{
    dVAR;
    int sig;
    PL_sig_pending = 0;
    for (sig = 1; sig < SIG_SIZE; sig++) {
        if (PL_psig_pend[sig]) {
            PERL_BLOCKSIG_ADD(set, sig);
            PL_psig_pend[sig] = 0;
            PERL_BLOCKSIG_BLOCK(set);
            (*PL_sighandlerp)(sig);
            PERL_BLOCKSIG_UNBLOCK(set);
        }
    }
}

> I don't think the fix is to add locking into the dispatcher :D

I stand by my claim that the code is safe and correct as is.

You have to try harder to come up with an example that shows how this
can fail. :)

Cheers,
-Jan

PS: See also here for the discussion about exactly the same topic in
May:

http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=20060509232219.
GT2831%5Bat%5Diabyn.com?show_headers=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.