test/java/lang/Runtime/exec/LotsOfDestroys.java

Print this page

        

@@ -24,24 +24,22 @@
 /**
  * @test
  * @bug 4637504 4653814
  * @summary Destroy should close stderr, stdout and stdin
  * @author kladko
+ * @run main/othervm LotsOfDestroys
  */
 
-import java.io.File;
-
 public class LotsOfDestroys {
     static final int RUNS = 400;
-    static final String ECHO = "/usr/bin/echo";
 
     public static void main(String[] args) throws Exception {
-        if (File.separatorChar == '\\' ||                // Windows
-                                !new File(ECHO).exists()) // no echo
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            System.err.println("Not for Windows");
             return;
-
+        }
         for (int i = 0; i<= RUNS; i++) {
-            Process process = Runtime.getRuntime().exec(ECHO + " x");
+            Process process = Runtime.getRuntime().exec(UnixCommands.echo() + " x");
             process.destroy();
         }
     }
 }