From 5d91e54de45de528a933585aed1891fb1b24eec4 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 14 Jun 2006 23:17:02 +0000 Subject: [PATCH] Spawn a thread to read output from the launched command for the few seconds that we linger following launch in case the command fails and generates output on stderr. --- .../threerings/getdown/launcher/Getdown.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index a1efc4b..0f48e6c 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -506,17 +506,36 @@ public abstract class Getdown extends Thread // on Windows 98 and ME we need to stick around and read the // output of stderr lest the process fill its output buffer and // choke, yay! + final InputStream stderr = proc.getErrorStream(); if (LaunchUtil.mustMonitorChildren()) { // close our window if it's around disposeContainer(); _status = null; - InputStream stderr = proc.getErrorStream(); BufferedReader reader = new BufferedReader( new InputStreamReader(stderr)); while (reader.readLine() != null) { // nothing doing! } Log.info("Process exited: " + proc.waitFor()); + } else { + // spawn a daemon thread that will catch the early bits of + // stderr in case the launch fails + Thread t = new Thread() { + public void run () { + try { + 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.start(); } }