I'm working on porting a Visual C++ application to GCC (should build on MingW and Linux).
The existing code uses __try { ... } __except(1) { ... }
blocks in a few places so that almost nothing (short of maybe out of memory type errors?) would make the program exit without doing some minimal logging.
What are the options for doing something similar with GCC?
Edit: Thanks for the pointer to /EH options in Visual Studio, what I need now is some examples on how to handle signals on Linux. I've found this message from 2002.
What other signals besides SIGFPE
and SIGSEVG
should I watch out for? (Mostly care about ones that might be raised from me doing something wrong)
Bounty Information: I want my application to be able to self-log as many error conditions as possible before it exits.
What signals might I get and which would generally be impossible to log an error message after? (Out of memory, what else?)
How can I handle exceptions and (most importantly) signals in a portable way that the code at least works the same on Linux and MingW. #ifdef is OK.
The reason I don't just have a wrapper process that logs the failure is that for performance reasons I save writing some data to disk till the last minute, so if something goes wrong I want to make all possible attempts to write the data out before exiting.