Menu

#52 Catch SIGTERM and SIGINT in the test runner and kill all currently running tests

Unstable (example)
closed-accepted
nobody
None
5
2015-06-14
2015-03-22
sdroege
No

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.

1 Attachments

Related

Patches: #52

Discussion

  • Branden Archer

    Branden Archer - 2015-04-28

    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?

     
  • sdroege

    sdroege - 2015-04-28

    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

     
  • Branden Archer

    Branden Archer - 2015-05-04

    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!

     
  • sdroege

    sdroege - 2015-05-04

    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

     
    • Branden Archer

      Branden Archer - 2015-05-07

      The same is probably also true on the other BSDs then?

      I'll tests some BSDs a little later on.

      You name is now added to the AUTHORS file in Check. Thanks for your
      contribution.

      • Branden

      On Mon, May 4, 2015 at 3:03 AM, sdroege sdroege@users.sf.net wrote:

      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


      Status: open
      Group: Unstable (example)
      Created: Sun Mar 22, 2015 11:17 AM UTC by sdroege
      Last Updated: Mon May 04, 2015 03:11 AM UTC
      Owner: nobody

      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.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/check/patches/52/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Patches: #52

  • Branden Archer

    Branden Archer - 2015-06-14
    • status: open --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.