From: brian Date: Sat, 8 May 2004 07:30:29 +0000 (-0700) Subject: fork/waitpid leak X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=2db6b04d7557a26e3b9e7440e7968aaec262216f;p=nestedvm.git fork/waitpid leak darcs-hash:20040508073029-24bed-204689d397194c5406a3341afdb19f87fb13f026.gz --- 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