diff options
author | Andrew Haley <aph@redhat.com> | 2005-12-14 20:26:30 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2005-12-14 20:26:30 +0000 |
commit | 4f9a6d459fc70db6947ed7e853c77f0b950669bd (patch) | |
tree | be49f6212eaf71cbf9f9894895d2f88a043b2a60 /libjava/gnu/java/rmi | |
parent | 3ce4312613bb39d065bb5d8d578d4c7f546d9ca7 (diff) | |
download | gcc-4f9a6d459fc70db6947ed7e853c77f0b950669bd.zip gcc-4f9a6d459fc70db6947ed7e853c77f0b950669bd.tar.gz gcc-4f9a6d459fc70db6947ed7e853c77f0b950669bd.tar.bz2 |
CompilerProcess.java: Use a new thread to handle stdout from the child process.
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
Diffstat (limited to 'libjava/gnu/java/rmi')
-rw-r--r-- | libjava/gnu/java/rmi/rmic/CompilerProcess.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libjava/gnu/java/rmi/rmic/CompilerProcess.java b/libjava/gnu/java/rmi/rmic/CompilerProcess.java index 3cf801d..09f8d9c 100644 --- a/libjava/gnu/java/rmi/rmic/CompilerProcess.java +++ b/libjava/gnu/java/rmi/rmic/CompilerProcess.java @@ -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. |