Date: Mon, 10 Nov 2008 11:07:38 +0100 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Alexey Dokuchaev <danfe@FreeBSD.org> Cc: svn-src-head@freebsd.org, Matteo Riondato <matteo@FreeBSD.org>, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184780 - head/usr.sbin/cron/crontab Message-ID: <861vxj6gid.fsf@ds4.des.no> In-Reply-To: <20081109084817.GA23323@FreeBSD.org> (Alexey Dokuchaev's message of "Sun, 9 Nov 2008 08:48:17 %2B0000") References: <200811090734.mA97YBld033553@svn.freebsd.org> <20081109084817.GA23323@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Alexey Dokuchaev <danfe@FreeBSD.org> writes: > Matteo Riondato <matteo@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 --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?861vxj6gid.fsf>