Let's copy the child's stderr to our own in both cases.

This commit is contained in:
Michael Bayne
2007-12-14 20:33:45 +00:00
parent 1f37906da8
commit 67c46834e6
@@ -709,10 +709,7 @@ public abstract class Getdown extends Thread
// close our window if it's around // close our window if it's around
disposeContainer(); disposeContainer();
_status = null; _status = null;
BufferedReader reader = new BufferedReader(new InputStreamReader(stderr)); copyStream(stderr, System.err);
while (reader.readLine() != null) {
// nothing doing!
}
Log.info("Process exited: " + proc.waitFor()); Log.info("Process exited: " + proc.waitFor());
} else { } else {
@@ -720,16 +717,7 @@ public abstract class Getdown extends Thread
// launch fails // launch fails
Thread t = new Thread() { Thread t = new Thread() {
public void run () { public void run () {
try { copyStream(stderr, System.err);
BufferedReader reader =
new BufferedReader(new InputStreamReader(stderr));
String line;
while ((line = reader.readLine()) != null) {
Log.warning(line);
}
} catch (IOException ioe) {
// oh well
}
} }
}; };
t.setDaemon(true); t.setDaemon(true);
@@ -903,6 +891,24 @@ public abstract class Getdown extends Thread
*/ */
protected abstract void exit (int exitCode); protected abstract void exit (int exitCode);
/**
* Copies the supplied stream from the specified input to the specified output. Used to copy
* our child processes stderr and stdout to our own stderr and stdout.
*/
protected static void copyStream (InputStream in, PrintStream out)
{
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = reader.readLine()) != null) {
out.print(line);
out.flush();
}
} catch (IOException ioe) {
Log.warning("Failure copying [in=" + in + ", out=" + out + ", error=" + ioe + "].");
}
}
/** Used to fetch a progress report URL. */ /** Used to fetch a progress report URL. */
protected class ProgressReporter extends Thread protected class ProgressReporter extends Thread
{ {