1. 30 Jan, 2009 1 commit
    • Jeff King's avatar
      t0005: use SIGTERM for sigchain test · 0ea80396
      Jeff King authored
      The signal tests consists of checking that each of our
      handlers is executed, and that the test program was killed
      by the final signal. We arbitrarily used SIGINT as the kill
      signal.
      
      However, some platforms (notably Solaris) will default
      SIGINT to SIG_IGN if there is no controlling terminal. In
      that case, we don't end up killing the program with the
      final signal and the test fails.
      
      This is a problem since the test script should not depend
      on outside factors; let's use SIGTERM instead, which should
      behave consistently.
      Signed-off-by: default avatarJeff King <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      0ea80396
  2. 22 Jan, 2009 1 commit
    • Jeff King's avatar
      chain kill signals for cleanup functions · 4a16d072
      Jeff King authored
      If a piece of code wanted to do some cleanup before exiting
      (e.g., cleaning up a lockfile or a tempfile), our usual
      strategy was to install a signal handler that did something
      like this:
      
        do_cleanup(); /* actual work */
        signal(signo, SIG_DFL); /* restore previous behavior */
        raise(signo); /* deliver signal, killing ourselves */
      
      For a single handler, this works fine. However, if we want
      to clean up two _different_ things, we run into a problem.
      The most recently installed handler will run, but when it
      removes itself as a handler, it doesn't put back the first
      handler.
      
      This patch introduces sigchain, a tiny library for handling
      a stack of signal handlers. You sigchain_push each handler,
      and use sigchain_pop to restore whoever was before you in
      the stack.
      Signed-off-by: default avatarJeff King <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      4a16d072