From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 554 invoked from network); 17 Jun 1997 14:31:01 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 17 Jun 1997 14:31:01 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA13385; Tue, 17 Jun 1997 10:16:48 -0400 (EDT) Resent-Date: Tue, 17 Jun 1997 10:16:48 -0400 (EDT) Message-Id: <199706171420.QAA05854@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: disown memory leak Date: Tue, 17 Jun 1997 16:20:31 +0200 From: Peter Stephenson Resent-Message-ID: <"71e5d.0.4H3.Fnffp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3251 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I noticed this some time ago but never did anything. Disown simply clears the job table entry for a job without deleting any of the associated structures. I don't see how this can possibly be anything other than a memory leak. What may happen, however, is a that the job exits and is handled by the signal handler while disown is busy deleting it (the opposite can't happen because signals are blocked while the handler is busy). I've therefore made deletejob() remove the process list as the first thing; then findproc() won't find the process if the job is already being deleted. If you were paranoid, you might want to block signals around deletejob(). *** Src/jobs.c.disown Tue Jun 17 15:51:45 1997 --- Src/jobs.c Tue Jun 17 16:12:21 1997 *************** *** 573,579 **** { struct process *pn, *nx; ! for (pn = jn->procs; pn; pn = nx) { nx = pn->next; zfree(pn, sizeof(struct process)); } --- 573,581 ---- { struct process *pn, *nx; ! pn = jn->procs; ! jn->procs = NULL; ! for (; pn; pn = nx) { nx = pn->next; zfree(pn, sizeof(struct process)); } *************** *** 1139,1150 **** printjob(job + jobtab, lng, 2); break; case BIN_DISOWN: ! { ! static struct job zero; ! ! jobtab[job] = zero; ! break; ! } } thisjob = ocj; } --- 1141,1148 ---- printjob(job + jobtab, lng, 2); break; case BIN_DISOWN: ! deletejob(jobtab + job); ! break; } thisjob = ocj; } -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.