bvdberg/ctest — pull request #8 by nicopernas (2014-09-03 22:40:54+00:00)
Title: Capture SIGSEGV signals

Hi,

I've been using ctest for the last month and I like it a lot. Thanks for developing it :)

At the moment I have several test cases built as different applications that run altogether. One thing that caught me a few times was the fact that if one of those test cases threw a seg fault I wouldn't know because there is no error being printed out. So I thought it might be a good idea to catch that signal, print a very visible message and then let the program die in piece.

This is what this patch is doing:

* It adds a SIGSEGV singal handler to capture signal and print a visible mesage letting the user know the test has seg fault.
* When the signal is caught the handler is fired off to print the message and then the same signal is sent back again to the process so it can be terminated.
* The signal hanlder gets registered before the main() function gets executed making use of GCC constructor attribute.
* The functionality can be enabled defining CTEST_SIG before including ctest.h

Other signals can be handled in the same way. I thought I'd add them between #defines but I'd like to know what do you think about this first.

Thanks,
Nico.