subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Shahaf <>
Subject Re: svn commit: r1727621 - in /subversion/trunk/subversion: svn/svn.c svnadmin/svnadmin.c svnbench/svnbench.c svnfsfs/svnfsfs.c svnlook/svnlook.c svnrdump/svnrdump.c svnsync/svnsync.c
Date Tue, 09 Feb 2016 03:23:47 GMT
Philip Martin wrote on Mon, Feb 08, 2016 at 10:33:05 +0000:
> 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);

This fixes the race I mentioned, but I think we have another problem
here: signum_cancelled is accessed by the signal handler so it must be
of type 'static volatile sig_atomic_t' (C89 §  but I don't
think anything guarantees that signal numbers are representable as
a sig_atomic_t.  On Linux/amd64 and FreeBSD they are, but that need not
be the case everywhere.

If we can't assume sig_atomic_t is at least as large as an int, I think
we have to use the following roundabout method:

    static volatile sig_atomic_t signum_cancelled[4] = {0, 0, 0, 0};
    static void signal_handler(int signum)
       if (signum == SIGINT)
         signum_cancelled[0] = TRUE;
    #ifdef SIGHUP
       if (signum == SIGHUP)
         signum_cancelled[1] = TRUE;
    #ifdef SIGTERM
       if (signum == SIGTERM)
         signum_cancelled[2] = TRUE;
    #ifdef SIGBREAK
       if (signum == SIGBREAK)
         signum_cancelled[3] = TRUE;

and then check which element(s) of the array are set to know which
signal to send to self.



View raw message