Some python functions can raise the SIGABRT signal via os.abort(). I am currently embedding a python interpreter in my C++ code but I don't want the execution to crash when this happens.
I tried it with a classical signal handling:
#include <signal.h>
void myhandler(int sig)
{
std::cout<< "Signal cought by C++ layer";
}
int main()
{
signal(SIGABRT, &myhandler);
Py_InitializeEx(skipSignalHandlerRegistration);
PyRun_SimpleString("import os\n"
"os.abort()");
....
}
After raising the signal, I actually end up inside the handler. But then the abort is executed anyway. It is actually the same problem as here. In the post the final solution was to fork a process and let it die when the signal is raised. I wanted to bring it up here to see if anyone has an alternative solution?