FAQ 26.10 What should the terminate() function do?

FAQ 26.10 What should the terminate() function do?

Log the error, release all known systemwide resources, and call abort().

The terminate function is called when the exception-handling system encounters an error from which it can't recover. This happens when main() fails to catch an exception and when a destructor called by the exception handler throws an exception. It is also the default behavior of the unexpected function. The set_terminate() function can be used to change the behavior of terminate().

The terminate function must not return, nor may it throw an exception. The best approach is to log the catastrophe (flush the file after logging the error, because abort() doesn't close open files), release any known systemwide resources (things that other applications depend on), and call abort().

C'est la vie.



C++ FAQs
C Programming FAQs: Frequently Asked Questions
ISBN: 0201845199
EAN: 2147483647
Year: 2005
Pages: 566
Authors: Steve Summit

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net