test/java/lang/Runtime/exec/StreamsSurviveDestroy.java

Print this page

        

@@ -28,11 +28,10 @@
  */
 
 import java.io.*;
 import java.util.concurrent.*;
 
-
 public class StreamsSurviveDestroy {
 
     private static class Copier extends Thread {
 
         String name;

@@ -100,11 +99,11 @@
 
     static void test() throws Exception {
         CountDownLatch latch = new CountDownLatch(2);
 
         System.err.println("test");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 false, false, latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
                                 false, false, latch);
         latch.await();    // Wait till both Copiers about to read

@@ -120,11 +119,11 @@
 
     static void testCloseBeforeDestroy() throws Exception {
         CountDownLatch latch = new CountDownLatch(2);
 
         System.err.println("testCloseBeforeDestroy");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 true, false, latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
                                 true, false, latch);
         latch.await();    // Wait till both Copiers about to read

@@ -141,11 +140,11 @@
     }
 
     static void testCloseAfterDestroy() throws Exception {
         CountDownLatch latch = new CountDownLatch(2);
         System.err.println("testCloseAfterDestroy");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 true, false,latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
                                 true, false, latch);
 

@@ -163,11 +162,11 @@
     }
 
     static void testInterrupt() throws Exception {
         CountDownLatch latch = new CountDownLatch(2);
         System.err.println("testInterrupt");
-        Process p = Runtime.getRuntime().exec("/bin/cat");
+        Process p = Runtime.getRuntime().exec(UnixCommands.cat());
         Copier cp1 = new Copier("out", p.getInputStream(), System.err,
                                 false, true, latch);
         Copier cp2 = new Copier("err", p.getErrorStream(), System.err,
                                 false, true, latch);
         latch.await();    // Wait till both Copiers about to read

@@ -186,12 +185,14 @@
 
     public static void main(String[] args) throws Exception {
 
         // Applies only to Solaris; Linux and Windows
         // behave a little differently
-        if (!System.getProperty("os.name").equals("SunOS"))
+        if (!System.getProperty("os.name").equals("SunOS")) {
+            System.err.println("For SunOS only");
             return;
+        }
 
         test();
         testCloseBeforeDestroy();
         testCloseAfterDestroy();
         testInterrupt();