How to catch exit() in embedded C++ module from python code?
Question
I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit. Is there a way to catch this event, or do I need to modify the library to handle error cases differently ?
Thank you very much,
Solution
You must modify the source of the library. There is no "exception handling" in C and exit()
does not return to the calling code under any circumstances.
OTHER TIPS
You can override the library linking with LD_LIBRARY_PATH and make your own exit function. Works fine.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow