From owner-freebsd-bugs Thu Apr 27 17:50:25 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from dnai.com (dnai.com [207.181.194.98]) by hub.freebsd.org (Postfix) with ESMTP id 6595637BCFC for ; Thu, 27 Apr 2000 17:50:23 -0700 (PDT) (envelope-from kientzle@acm.org) Received: from azoth.dnai.com (azoth.dnai.com [207.181.194.94]) by dnai.com (8.9.3/8.9.3) with ESMTP id RAA59098 for ; Thu, 27 Apr 2000 17:50:23 -0700 (PDT) Received: from acm.org (dnai-216-15-121-177.cust.dnai.com [216.15.121.177]) by azoth.dnai.com (8.9.3/8.9.3) with ESMTP id RAA81826 for ; Thu, 27 Apr 2000 17:50:21 -0700 (PDT) Message-ID: <3908E04C.1D7C42C9@acm.org> Date: Thu, 27 Apr 2000 17:50:20 -0700 From: Tim Kientzle Reply-To: kientzle@acm.org X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 3.3-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-bugs@freebsd.org Subject: Fix to CRON daemon... Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 > > 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