1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +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,23 +434,49 @@ 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);
if (MIPlugin.getDefault().isDebugging()) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < args.length; ++i) {
sb.append(args[i]);
sb.append(' ');
}
MIPlugin.getDefault().debugLog(sb.toString());
}
MISession miSession;
MISession miSession = null;
MIProcess pgdb = null;
boolean failed = false;
try {
pgdb = new MIProcessAdapter(args, launchTimeout, monitor);
if (MIPlugin.getDefault().isDebugging()) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < args.length; ++i) {
sb.append(args[i]);
sb.append(' ');
}
MIPlugin.getDefault().debugLog(sb.toString());
}
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);