I'm writing a unit test harness and would like to establish the behavior that if the child process segfaulted, I want to re-run it again under GDB.
The general approach is to execute all tests in parallel, this is done by assembling the commands together and piping the commands into xargs -P 0 -L 1 -I CMD bash -c CMD
, and then I want to catch any of these inner processes that segfaulted, and re-run them sequentially under gdb. Note that this is a different thing than catching their return values, which I will continue to treat for test pass/fail purposes.
Obviously a segfaulting test is a failing test... the point is to make it automagically produce a gdb session with the segfault caught, for maximum productivity :)
I know that the WTERMSIG
macro can be used in C to check if a child process segfaulted once it exits. I could certainly write a small C/C++ helper program to implement this determination for me but it would be nice if there was a built in way to do this with bash
.