From owner-freebsd-stable@FreeBSD.ORG Mon Aug 25 05:38:00 2003 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1506416A4DA; Mon, 25 Aug 2003 05:38:00 -0700 (PDT) Received: from www.svzserv.kemerovo.su (www.svzserv.kemerovo.su [213.184.65.80]) by mx1.FreeBSD.org (Postfix) with ESMTP id 01EF843FD7; Mon, 25 Aug 2003 05:37:58 -0700 (PDT) (envelope-from eugen@kuzbass.ru) Received: from kuzbass.ru (kost [213.184.65.82])h7PCbsel042398; Mon, 25 Aug 2003 20:37:55 +0800 (KRAST) (envelope-from eugen@kuzbass.ru) Message-ID: <3F4A02E8.F80F62A7@kuzbass.ru> Date: Mon, 25 Aug 2003 20:36:56 +0800 From: Eugene Grosbein Organization: SVZServ X-Mailer: Mozilla 4.8 [en] (Win98; U) X-Accept-Language: ru,en MIME-Version: 1.0 To: David Schultz References: <20030815211321.A11482@grosbein.pp.ru> <20030824185618.GA3837@HAL9000.homeunix.com> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit cc: stable@FreeBSD.ORG cc: bug-followup@FreeBSD.ORG Subject: Re: bin/55346: /bin/sh eats memory and CPU infinitely X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Aug 2003 12:38:00 -0000 David Schultz wrote: > > On Fri, Aug 15, 2003, Eugene Grosbein wrote: > > I think I've found a memory leak in /bin/sh. > > There is a case when dowait() and does frees resources of > > completed job correctly. Here is a patch: > > > > Index: jobs.c > > =================================================================== > > RCS file: /home/ncvs/src/bin/sh/jobs.c,v > > retrieving revision 1.27.2.11 > > diff -u -r1.27.2.11 jobs.c > > --- jobs.c 22 Jul 2003 13:11:26 -0000 1.27.2.11 > > +++ jobs.c 15 Aug 2003 13:02:23 -0000 > > @@ -960,10 +960,8 @@ > > if (jp->state != state) { > > TRACE(("Job %d: changing state from %d to %d\n", jp - jobtab + 1, jp->state, state)); > > jp->state = state; > > -#if JOBS > > if (done) > > - deljob(jp); > > -#endif > > + freejob(jp); > > } > > } > > } > > I don't think this is right. This will cause jobs to be freed > even when they shouldn't be. Please give me an example when job should not be freed in dowait(). > The general problem you're complaining about (here and earlier) is > that /bin/sh only checks for the termination of backgrounded > children when it displays a prompt, and of course it doesn't do > that in the middle of a while loop. I don't know what the various > standards have to say about this, but the behavior is probably > just a bug. Yes it is. Both bash and zsh do not behave so.