1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Close the pty if the session creation failed.

This commit is contained in:
Mikhail Khodjaiants 2006-04-21 15:48:17 +00:00
parent 6f82c41296
commit 7729196702
2 changed files with 42 additions and 12 deletions

View file

@ -1,3 +1,7 @@
2006-04-21 Mikhail Khodjaiants
Close the pty if the session creation failed.
* MIPlugin.java
2006-04-18 Mikhail Khodjaiants
Duplicate message key.
* MIPluginResources.properties

View file

@ -434,7 +434,12 @@ public class MIPlugin extends Plugin {
}
String[] args = (String[])argList.toArray(new String[argList.size()]);
int launchTimeout = MIPlugin.getDefault().getPluginPreferences().getInt(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT);
MIProcess pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
MISession miSession = null;
MIProcess pgdb = null;
boolean failed = false;
try {
pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
if (MIPlugin.getDefault().isDebugging()) {
StringBuffer sb = new StringBuffer();
@ -445,12 +450,33 @@ public class MIPlugin extends Plugin {
MIPlugin.getDefault().debugLog(sb.toString());
}
MISession miSession;
try {
miSession = createMISession0(sessionType, pgdb, factory, pty, getCommandTimeout());
} catch (MIException e) {
pgdb.destroy();
failed = true;
throw e;
} catch(IOException e ) {
failed = true;
throw e;
} finally {
if (failed) {
// Kill gdb
if ( pgdb != null )
pgdb.destroy();
// Shutdown the pty console.
if (pty != null) {
try {
OutputStream out = pty.getOutputStream();
if (out != null) {
out.close();
}
InputStream in = pty.getInputStream();
if (in != null) {
in.close();
}
} catch (IOException e) {
}
}
}
}
return new Session(miSession);