Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch exit() in embedded C++ module from python code?

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,

like image 428
Clément M Avatar asked Sep 17 '09 15:09

Clément M


1 Answers

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.

like image 133
Aaron Digulla Avatar answered Oct 07 '22 23:10

Aaron Digulla