Ignoring SMP write issues, I think that this code has a race condition
already:
Thread 1: Thread 2:
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);
PERL_BLOCKSIG_ADD(set, sig);
PL_psig_pend[sig] = 0;
PERL_BLOCKSIG_BLOCK(set);
(*PL_sighandlerp)(sig);
PERL_BLOCKSIG_UNBLOCK(set);
PL_psig_pend[sig] = 0;
PERL_BLOCKSIG_BLOCK(set);
(*PL_sighandlerp)(sig);
PERL_BLOCKSIG_UNBLOCK(set);
}
}
}
Signals are per process (unless I'm confused)
If a scheduler stops thread 1, and thread 2 runs the same code at the point
shown, then the intended protection of the blocked signals won't be there.
Nicholas Clark