Domanda

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).

È stato utile?

Soluzione

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 the signal() interface will be uninstalled immediately prior to execution of the handler. Permanent handlers must therefore be reinstalled by a call to signal() 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?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top