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

Print this page

        

*** 29,47 **** */ 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 return; ! for (int i = 0; i<= RUNS; i++) { ! Process process = Runtime.getRuntime().exec(ECHO + " x"); process.destroy(); } } } --- 29,48 ---- */ import java.io.File; public class LotsOfDestroys { + static final boolean isWindows = + System.getProperty("os.name", "unknown").startsWith("Windows"); static final int RUNS = 400; public static void main(String[] args) throws Exception { ! if (isWindows) { ! System.err.println("Not for Windows"); return; ! } for (int i = 0; i<= RUNS; i++) { ! Process process = Runtime.getRuntime().exec("echo x"); process.destroy(); } } }