Clean exit on signal
807575May 18 2001 — edited Jun 18 2001We're in the process of moving to C++ 5.1/WorkShop 6 from 4.2. Under 4.2 our apps trapped certain UNIX signals, and threw an exception. This allowed our apps to cleanly shutdown as the stack was unwound and destructors invoked.
This no longer works in 5.1 (the manual explicitly says not to throw exceptions from signal handlers). Is there a clean way to "re-enter" the C++ environment from a signal handler so we can throw an exception?
We have tried throwing from the signal handler in 5.1, and the signal is not picked up by any catch block, not one typed explicitly for this exception, and not even catch(...). I have not attempted to check if stack unwinding is occuring, as the catch problem is a showstopper.
We chose to use an exception under 4.2 as we had already coded our apps to shut down cleanly on an unexpected exception.
Any thoughts on how to handle this? The docs say to set a flag in the signal handler and have the C++ code poll the flag. This is a very intrusive way of dealing with it.