#define _POSIX_SOURCE #include #include int *a; class FoobarException { int thingy; }; void signal_handler(int signum, siginfo_t *info, void *) { FoobarException *f = new FoobarException; throw f; } int main() { struct sigaction act; act.sa_sigaction = signal_handler; sigemptyset (&act.sa_mask); act.sa_flags = SA_SIGINFO; sigaction (11, &act, NULL); try { printf("%d\n", *a); } catch (FoobarException *f) { printf("Hello!\n"); } }