Globally handling uncaught exceptions and signals in C++