8160151: java/lang/ProcessBuilder/Zombies.java failed with error "1 zombies!"
authorrriggs
Wed, 03 Aug 2016 12:55:44 -0400
changeset 40117 d7a28ec54d11
parent 40116 9bde91c0d0ef
child 40118 f63c761ec2d2
8160151: java/lang/ProcessBuilder/Zombies.java failed with error "1 zombies!" Reviewed-by: dfuchs
jdk/test/TEST.groups
jdk/test/java/lang/ProcessBuilder/Zombies.java
--- a/jdk/test/TEST.groups	Wed Aug 03 08:13:45 2016 -0700
+++ b/jdk/test/TEST.groups	Wed Aug 03 12:55:44 2016 -0400
@@ -27,7 +27,6 @@
 
 tier1 = \
     :jdk_lang \
-    -java/lang/ProcessBuilder/Zombies.java \
     :jdk_util \
     -java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
     -java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
@@ -38,7 +37,6 @@
     tools/pack200
 
 tier2 = \
-    java/lang/ProcessBuilder/Zombies.java \
     java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
     java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
     :jdk_io \
--- a/jdk/test/java/lang/ProcessBuilder/Zombies.java	Wed Aug 03 08:13:45 2016 -0700
+++ b/jdk/test/java/lang/ProcessBuilder/Zombies.java	Wed Aug 03 12:55:44 2016 -0400
@@ -23,7 +23,8 @@
 
 /*
  * @test
- * @bug 6474073
+ * @run main/othervm Zombies
+ * @bug 6474073 6180151
  * @key intermittent
  * @summary Make sure zombies don't get created on Unix
  * @author Martin Buchholz
@@ -65,22 +66,21 @@
 
         Process p = rt.exec(TrueCommand);
         ProcessHandle pp = p.toHandle().parent().orElse(null);
-        System.out.printf("pid: %d, parent: %s%n", p.getPid(), pp);
+        System.out.printf("%s pid: %d, parent: %s%n", TrueCommand, p.getPid(), pp);
         p.waitFor();
 
         // Count all the zombies that are children of this Java process
         final String[] zombieCounter = {
             "/usr/bin/perl", "-e",
-            "exit @{[`/bin/ps -eo ppid,s` =~ /^ *@{[getppid]} +Z$/mog]}"
+                "$a=`/bin/ps -eo ppid,pid,s,command`;" +
+                        "print @b=$a=~/^ *@{[getppid]} +[0-9]+ +Z.*$/mog;" +
+                        "exit @b"
         };
 
-        int zombies = rt.exec(zombieCounter).waitFor();
+        ProcessBuilder pb = new ProcessBuilder(zombieCounter);
+        pb.inheritIO();
+        int zombies = pb.start().waitFor();
         if (zombies != 0) {
-            // Log remaining processes
-            ProcessBuilder pb = new ProcessBuilder("/bin/ps", "-ef");
-            pb.inheritIO();
-            Process p2 = pb.start();
-            p2.waitFor();
             throw new Error(zombies + " zombies!");
         }
     }