8059034: ProcessTools.startProcess() might leak processes
Reviewed-by: sla, miauno
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Wed Sep 24 15:02:19 2014 -0700
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Thu Sep 25 12:51:43 2014 +0200
@@ -36,12 +36,10 @@
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import java.util.function.Consumer;
-import java.util.stream.Collector;
import java.util.stream.Collectors;
import sun.management.VMManagement;
@@ -177,6 +175,11 @@
for(Map.Entry<Thread, StackTraceElement[]> s : Thread.getAllStackTraces().entrySet()) {
printStack(s.getKey(), s.getValue());
}
+
+ if (p.isAlive()) {
+ p.destroyForcibly();
+ }
+
stdoutTask.cancel(true);
stderrTask.cancel(true);
throw e;