From 2db6b04d7557a26e3b9e7440e7968aaec262216f Mon Sep 17 00:00:00 2001 From: brian Date: Sat, 8 May 2004 00:30:29 -0700 Subject: [PATCH] fork/waitpid leak darcs-hash:20040508073029-24bed-204689d397194c5406a3341afdb19f87fb13f026.gz --- src/org/ibex/nestedvm/UnixRuntime.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/org/ibex/nestedvm/UnixRuntime.java b/src/org/ibex/nestedvm/UnixRuntime.java index e3afe98..0bed8ed 100644 --- a/src/org/ibex/nestedvm/UnixRuntime.java +++ b/src/org/ibex/nestedvm/UnixRuntime.java @@ -86,14 +86,21 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { UnixRuntime[] tasks = gs.tasks; synchronized(gs) { if(pid != 0) { - if(tasks[pid] == null || tasks[pid].pid != pid) throw new Error("should never happen"); + UnixRuntime prev = tasks[pid]; + if(prev == null || prev == this || prev.pid != pid || prev.parent != parent) + throw new Error("should never happen"); + synchronized(parent.children) { + int i = parent.activeChildren.indexOf(prev); + if(i == -1) throw new Error("should never happen"); + parent.activeChildren.set(i,this); + } } else { int newpid = -1; int nextPID = gs.nextPID; - for(int i=nextPID;i