changeset 26734:8ca968d8186b

8059034: ProcessTools.startProcess() might leak processes Reviewed-by: sla, miauno
author jbachorik
date Thu, 25 Sep 2014 12:51:43 +0200
parents bb835fd801b6
children 4502faa0cc22
files jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;