It would appear that the implementation of raise(sig)
resets the handler installed with signal(sig, handlerFunction)
, that is, in a multithreaded program, the first thread to call abort()
will call the custom handlerFunction
, but if any other threads then calls abort, this other thread will just call exit(3)
.
Apparently, the behavior of signal + raise is specified as such. From Wikipedia's article on sigaction
:
... replacement of the unreliable and deprecated
signal()
function. Signal handlers installed by thesignal()
interface will be uninstalled immediately prior to execution of the handler. Permanent handlers must therefore be reinstalled by a call tosignal()
during the handler's execution, causing ...
So it seems this is expected behavior. (Of course, the MSDN docs seem to completely fail to mention this.)
Question here on SO: What is the difference between sigaction and signal?