fork(2) download
  1. #include <iostream>
  2. #include <exception>
  3.  
  4. using namespace std;
  5.  
  6. void f()
  7. {
  8. throw 1;
  9. }
  10.  
  11. void g() noexcept
  12. {
  13. throw 1;
  14. }
  15.  
  16. int main()
  17. {
  18. set_terminate([](){ cout << "terminate() called\n"; exit(1);});
  19. try {
  20. f();
  21. } catch(...)
  22. {
  23. cout << "Catch them!\n";
  24. }
  25. try {
  26. g();
  27. } catch(...)
  28. {
  29. cout << "Catch them!\n";
  30. }
  31. }
  32.  
Runtime error #stdin #stdout 0s 4340KB
stdin
Standard input is empty
stdout
Catch them!
terminate() called