8059034: ProcessTools.startProcess() might leak processes
authorjbachorik
Thu, 25 Sep 2014 12:51:43 +0200
changeset 26734 8ca968d8186b
parent 26733 bb835fd801b6
child 26735 4502faa0cc22
8059034: ProcessTools.startProcess() might leak processes Reviewed-by: sla, miauno
jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
--- 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;