zsh-workers
 help / color / mirror / code / Atom feed
* disown memory leak
@ 1997-06-17 14:20 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 1997-06-17 14:20 UTC (permalink / raw)
  To: Zsh hackers list

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-06-17 14:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-17 14:20 disown memory leak Peter Stephenson

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).