Alexey Dokuchaev <[EMAIL PROTECTED]> writes:
> Matteo Riondato <[EMAIL PROTECTED]> writes:
> > +void
> > +static remove_tmp(int sig)
> > +{
> > +   if (tmp_path) {
> > +           unlink(tmp_path);
> > +   }
> > +   exit(ERROR_EXIT);
> > +}
> This looks weird: `static' should be on same line as `void' as `static
> void' (so ^remove_tmp would match).  It will also always exit with
> ERROR_EXIT, which does not look right, does it?

The correct solution would be:

static void
remove_tmp(int sig)
{

        (void)sig;
        if (tmp_path)
                unlink(tmp_path);
        _exit(1)
}

This assumes that tmp_path is atomic.  In theory, the only type of
global variable you can access from a signal handler is sig_atomic_t,
but in practice, any volatile variable will work.

(yes, the unconditional _exit() is correct)

For bonus points, you should re-throw the signal rather than _exit():

static void
remove_tmp(int sig)
{

        if (tmp_path)
                unlink(tmp_path);
        signal(sig, SIG_DFL);
        raise(sig);
}

BTW, the "void (*f[3])()" thing in replace_cmd() is pointless; just
reset the three signals to SIG_DFL.

DES
-- 
Dag-Erling Smørgrav - [EMAIL PROTECTED]
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to