UPDATE:
Note: The signal-handler files can't be compiled with the -O2 switch and it's probably best if you only trap the signals you really intend to redirect, such as SIGSEGV (11). If you compile what we have here with the -O2 switch your cpu may hang if you try to exit using Ctrl-C for example. See implementation notes added to signal-handler.c below.
See part 1 for main functions to test this in C and C++.
To throw and catch stuff like segfaults in C++ it's...