Attached patch catches SIGTERM and SIGINT in the test runner and kills all currently running tests.
Otherwise e.g. ctrl+c in the test runner exits the test runner, while the test
itself is still running in the background, uses CPU and memory and potentially
never exits (e.g. if the test ran into a deadlock or infinite loop).
The reason why we have to manually kill the actual tests is that after
forking they will be moved to their own process group, and as such are
not receiving any signals sent to the test runner anymore. This is supposed
to be done to make it easier to kill a test, which it only really does if
the test itself is forking off new processes.
This fix is not complete though. SIGKILL can't be caught at all, and error
signals like SIGSEGV, SIGFPE are currently not caught. The latter will only
happen if there is a bug in the test runner itself, and as such seem less
important.
Thanks for the patch.
I've a question about one of the changes in the signal hander. Right after
killpg(group_pid, child_sig);
is invoked to kill the forked unit test, the original signal hander is restored
sigaction(sig_nr, &old_action[idx], NULL);
then we kill our own process group
killpg(own_group_pid, sig_nr);
The expectation is that the last killpg will kill the main process, right? If that is so, what is the benefit of restoring the previous signal handler before doing so?
Yes, that last killpg() should kill the main process group. The reason for restoring the original signal handler is mostly for symmetry. At least on Linux, sending the kill signal from the signal handler again makes it stop the process. But I'm not 100% sure this is correct everywhere, maybe on other platforms it will call into our own signal handler again?
It wasn't completely clear from the documentation for me
It turns out that on OSX if the original signal hander is not restored or disabled that the same handler gets called again. Restoring the handler is necessary.
Your patch will be accepted into Check. Additionally, I would like to add your name to Check's Authors file due to your contribution. What name may I record?
Thanks for the patch!
Ah, good to know. Thanks! The same is probably also true on the other BSDs then?
My name is Sebastian Dröge, if you also need a mail address you can take sebastian@centricular.com
I'll tests some BSDs a little later on.
You name is now added to the AUTHORS file in Check. Thanks for your
contribution.
On Mon, May 4, 2015 at 3:03 AM, sdroege sdroege@users.sf.net wrote:
Related
Patches:
#52