]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
CompilerProcess.java: Use a new thread to handle stdout from the child process.
authorAndrew Haley <aph@redhat.com>
Wed, 14 Dec 2005 20:26:30 +0000 (20:26 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Wed, 14 Dec 2005 20:26:30 +0000 (20:26 +0000)
2005-12-14  Andrew Haley  <aph@redhat.com>

        * gnu/java/rmi/rmic/CompilerProcess.java: Use a new thread to
        handle stdout from the child process.

From-SVN: r108536

libjava/ChangeLog
libjava/gnu/java/rmi/rmic/CompilerProcess.java

index bee1eb0d9071e35798d482721cc5d2a63f6a6fa6..be55e41de0145ec3521f599a568a027d4713c1f2 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-14  Andrew Haley  <aph@redhat.com>
+
+       * gnu/java/rmi/rmic/CompilerProcess.java: Use a new thread to
+       handle stdout from the child process.
+
 2005-12-14  Tom Tromey  <tromey@redhat.com>
 
        PR classpath/25389:
index 3cf801d42d28199b0344101bb337aac0b8fd86bc..09f8d9c07b47c215c2e691b2abca8ffe3fde0100 100644 (file)
@@ -89,10 +89,27 @@ public abstract class CompilerProcess extends Compiler
     String[] args = computeArguments (name);
     Process p = Runtime.getRuntime ().exec (args);
 
-    /* Print compiler output to System.out. */
-    InputStream procin = p.getInputStream();
-    for (int ch = procin.read(); ch != -1; ch = procin.read())
-      System.out.print((char) ch);
+    /* Print compiler output to System.out.  Do this asynchronously so
+       that the compiler never blocks writing to its stdout.  */
+    {
+      final InputStream procin = p.getInputStream();
+      final Thread copier = new Thread() 
+       {
+         public void run()
+         {
+           try
+             {
+               for (int ch = procin.read(); ch != -1; ch = procin.read())
+                 System.out.print((char) ch);
+             }
+           catch (java.io.IOException _)
+             {
+             }
+         }
+       };
+
+      copier.start();
+    }
 
     /* Collect compiler error output in a buffer.
      * If compilation fails, it will be used for an error message.