Daniel Shahaf <d...@daniel.shahaf.name> writes:

> I think we have two options to fix this: either make signum_cancelled
> a write-once variable (never write to it if it's nonzero), or have the
> handler install SIG_IGN handlers for all signals we catch, not just for
> one of them.  Or perhaps both?  The former approach seems more robust
> but the latter seems like a good idea in its own right.

There is a race right at the end but there is also a race with a much
bigger window earlier.  When a signal, say SIGINT, causes the program to
begin the process of cancelling then a second signal, say SIGTERM, can
arrive before we get to the exit code.

When there are two different signals I don't think there is a 'correct'
signal with which to exit, all that matters is that we exit with one of
the signals.  So how about:

      int saved_signum = signum_cancelled;
      apr_signal(saved_signum, SIG_DFL);
      kill(getpid(), saved_signum);

-- 
Philip Martin
WANdisco

Reply via email to