Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Apr 2000 17:50:20 -0700
From:      Tim Kientzle <kientzle@acm.org>
To:        freebsd-bugs@freebsd.org
Subject:   Fix to CRON daemon...
Message-ID:  <3908E04C.1D7C42C9@acm.org>

next in thread | raw e-mail | index | archive | help
Some folks I work with found a problem in
BSDI's 'cron' daemon.  This ultimately resulted
in the attached message from Paul Vixie; I notice
FreeBSD is also using Vixie cron.

			- Tim Kientzle


-------- Original Message --------
> To: bsdi-users@bsdi.com
> Subject: Re: Cron setting SIGCHLD to SIG_IGN
> References: <200004271826.OAA23896@iridium.mv.net>
> In-Reply-To: mem@mv.mv.com's message of "27 Apr 2000 11:22:33 -0700"
> Date: Thu, 27 Apr 2000 14:47:02 -0700
> From: Paul A Vixie <vixie@mibh.net>
> 
> mem@mv.mv.com ("Mark E. Mallett") writes:
> 
> > Looking at the cron source code, I do see that cron is forcing
> > SIGCHLD to SIG_IGN for the children that it spawns.  I'm afraid that
> > the reasoning behind this move escapes me.
> 
> It's because cron (then called crond) was the first program I ever wrote
> that used signals or called fork or exec.  This was in 1986, just after
> 4.3BSD came out, and well before signals had been posixified.  signal(2)
> says, quite clearly:
> 
>      When a process which has installed signal handlers forks, the child pro-
>      cess inherits the signals.  All caught signals may be reset to their de-
>      fault action by a call to the execve(2) function; ignored signals remain
>      ignored.
> 
> This means that having set SIGCHLD to SIG_IGN for my own purposes, I really
> needed (and apparently still need) to set it back to SIG_DFL before fork()'ing
> to run each command found in a crontab.  Ouch!  Sorry, all.  Here's a patch
> against cron 4.0 (see ftp://ftp.isc.org/isc/cron/, since this is more recent
> than what ships with BSD/OS).  The patch ought to apply, with some fuzz, to
> the shipping version.
> 
> Index: do_command.c
> ===================================================================
> RCS file: /proj/src/isc/cvs-1/cron/do_command.c,v
> retrieving revision 1.4
> diff -u -r1.4 do_command.c
> --- do_command.c	2000/01/02 20:53:41	1.4
> +++ do_command.c	2000/04/27 18:45:37
> @@ -222,6 +222,13 @@
>  		chdir(env_get("HOME", e->envp));
>  
>  		/*
> +		 * Since ignored signals remain ignored after fork()/exec(),
> +		 * we need to unignore our ignored signals before letting
> +		 * some unsuspecting user level command inherit them.
> +		 */
> +		(void) signal(SIGCHLD, SIG_DFL);
> +
> +		/*
>  		 * Exec the command.
>  		 */
>  		{
> 
> ---------------------------------------------------------------------
> Searchable Archive: http://www.nexial.com/cgi-bin/bsdibody
> To unsubscribe, e-mail: bsdi-users-unsubscribe@mailinglists.org
> For additional commands, e-mail: bsdi-users-help@mailinglists.org
>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3908E04C.1D7C42C9>