svn commit: r184780 - head/usr.sbin/cron/crontab
Dag-Erling Smørgrav
des at des.no
Mon Nov 10 02:07:40 PST 2008
Alexey Dokuchaev <danfe at FreeBSD.org> writes:
> Matteo Riondato <matteo at FreeBSD.org> 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 - des at des.no
More information about the svn-src-all
mailing list