Stupid behaviour in newlib?
Posted: Sun Nov 18, 2007 8:59 am
After spending ages wondering why my signals weren't being delivered I peered into the newlib source code for raise():
I've highlighted the interesting part in bold: It removes the signal handler whenever raise() is called! WHAT?!?! why? I've implemented an ugly hack involving calling signal() three times whenever I send a signal to save and reinstall the correct signal handler but I shouldn't have to do this - this behaviour is not in the POSIX spec - what's it all about?
Any ideas?
Code: Select all
func = ptr->_sig_func[sig];
if (func == SIG_DFL)
return _kill_r (ptr, _getpid_r (ptr), sig);
else if (func == SIG_IGN)
return 0;
else if (func == SIG_ERR)
{
ptr->_errno = EINVAL;
return 1;
}
else
{
[b]ptr->_sig_func[sig] = SIG_DFL;[/b]
func (sig);
return 0;
}
Any ideas?