#include #include #include #include void throw_signal( int signum ) { // fprintf(stderr,"throw_signal: before throw; signum=%d\n",signum);fflush(stderr); throw std::runtime_error ("throw_signal"); } int main() { struct sigaction new_action, d_old_action; memset (&new_action, 0, sizeof (new_action)); new_action.sa_handler = throw_signal; sigemptyset (&new_action.sa_mask); new_action.sa_flags = 0; if (sigaction (SIGSEGV, &new_action, &d_old_action) < 0){ perror ("sigaction (install new)"); throw std::runtime_error ("sigaction"); } try { int j = *((int *)NULL); } catch (...){ printf("caught exception\n"); } }