From owner-freebsd-bugs@FreeBSD.ORG Sun Aug 24 12:00:38 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AEBDE16A4C3 for ; Sun, 24 Aug 2003 12:00:38 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 535A243FBF for ; Sun, 24 Aug 2003 12:00:38 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h7OJ0cUp025459 for ; Sun, 24 Aug 2003 12:00:38 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h7OJ0c7n025458; Sun, 24 Aug 2003 12:00:38 -0700 (PDT) Date: Sun, 24 Aug 2003 12:00:38 -0700 (PDT) Message-Id: <200308241900.h7OJ0c7n025458@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: David Schultz Subject: Re: bin/55346: /bin/sh eats memory and CPU infinitely X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: David Schultz List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2003 19:00:38 -0000 The following reply was made to PR bin/55346; it has been noted by GNATS. From: David Schultz To: Eugene Grosbein Cc: stable@FreeBSD.ORG, bug-followup@FreeBSD.ORG Subject: Re: bin/55346: /bin/sh eats memory and CPU infinitely Date: Sun, 24 Aug 2003 11:56:18 -0700 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. 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.