From owner-svn-src-head@FreeBSD.ORG Mon Nov 10 10:07:40 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E88F106567F; Mon, 10 Nov 2008 10:07:40 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 3C4108FC23; Mon, 10 Nov 2008 10:07:40 +0000 (UTC) (envelope-from des@des.no) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 1E3726D452; Mon, 10 Nov 2008 10:07:39 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 053C484490; Mon, 10 Nov 2008 11:07:39 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Alexey Dokuchaev References: <200811090734.mA97YBld033553@svn.freebsd.org> <20081109084817.GA23323@FreeBSD.org> Date: Mon, 10 Nov 2008 11:07:38 +0100 In-Reply-To: <20081109084817.GA23323@FreeBSD.org> (Alexey Dokuchaev's message of "Sun, 9 Nov 2008 08:48:17 +0000") Message-ID: <861vxj6gid.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, Matteo Riondato , svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184780 - head/usr.sbin/cron/crontab X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2008 10:07:40 -0000 Alexey Dokuchaev writes: > Matteo Riondato 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