1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Try to catch upfront errors like bad arguments by checking

if the process is still alive.
This commit is contained in:
Alain Magloire 2002-11-01 16:44:34 +00:00
parent b22d79fa61
commit 9ecebfa287

View file

@ -4,8 +4,10 @@
*/
package org.eclipse.cdt.debug.mi.core;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
@ -107,6 +109,27 @@ public class MISession extends Observable {
rxQueue = new CommandQueue();
eventQueue = new Queue();
// The Process may have terminated earlier because
// of bad arguments etc .. check this here and bail out.
try {
process.exitValue();
InputStream err = process.getErrorStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(err));
String line = null;
try {
line = reader.readLine();
reader.close();
} catch (Exception e) {
// the reader may throw a NPE.
}
if (line == null) {
line = "Process Terminated";
}
throw new MIException(line);
} catch (IllegalThreadStateException e) {
// Ok, it means the process is alive.
}
txThread = new TxThread(this);
rxThread = new RxThread(this);
eventThread = new EventThread(this);