zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: disown memory leak
Date: Tue, 17 Jun 1997 16:20:31 +0200	[thread overview]
Message-ID: <199706171420.QAA05854@hydra.ifh.de> (raw)

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 <pws@ifh.de>       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.


                 reply	other threads:[~1997-06-17 14:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199706171420.QAA05854@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).