[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

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

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Tue, 09 Feb 2016 03:23:47 +0000

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.

Agreed.

> 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 §4.7.1.1)... 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;
    #endif
    #ifdef SIGTERM
       if (signum == SIGTERM)
         signum_cancelled[2] = TRUE;
    #endif
    #ifdef SIGBREAK
       if (signum == SIGBREAK)
         signum_cancelled[3] = TRUE;
    #endif
    }

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

Cheers,

Daniel
Received on 2016-02-09 04:30:30 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.