Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Blackburn2010-05-27 06:01:52 -0400
committerJames Blackburn2010-05-27 06:01:52 -0400
commitb911acf559b72b746127a8820dac1b904dbf2972 (patch)
tree979887e127b0f0dd5eafb1137068b459bf237f07 /core/org.eclipse.cdt.core.win32/src
parentfce5016ea7812dcd51a5a62e5554f2bc07be8f25 (diff)
downloadorg.eclipse.cdt-b911acf559b72b746127a8820dac1b904dbf2972.tar.gz
org.eclipse.cdt-b911acf559b72b746127a8820dac1b904dbf2972.tar.xz
org.eclipse.cdt-b911acf559b72b746127a8820dac1b904dbf2972.zip
Bug 314504 ProcessList leaks file descriptors during #getProcessList()
Diffstat (limited to 'core/org.eclipse.cdt.core.win32/src')
-rw-r--r--core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
index c818292098..e9ba0a98c0 100644
--- a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
+++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/ProcessList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,6 +43,7 @@ public class ProcessList implements IProcessList {
String command = null;
InputStream in = null;
Bundle bundle = Platform.getBundle(CCorePlugin.PLUGIN_ID);
+ IProcessInfo[] procInfos = NOPROCESS;
try {
URL url = FileLocator.find(bundle, new Path("$os$/listtasks.exe"), null); //$NON-NLS-1$
@@ -53,16 +54,23 @@ public class ProcessList implements IProcessList {
if (file.exists()) {
command = file.getCanonicalPath();
if (command != null) {
- p = ProcessFactory.getFactory().exec(command);
- in = p.getInputStream();
- InputStreamReader reader = new InputStreamReader(in);
- return parseListTasks(reader);
+ try {
+ p = ProcessFactory.getFactory().exec(command);
+ in = p.getInputStream();
+ InputStreamReader reader = new InputStreamReader(in);
+ procInfos = parseListTasks(reader);
+ } finally {
+ if (in != null)
+ in.close();
+ if (p != null)
+ p.destroy();
+ }
}
}
}
} catch (IOException e) {
}
- return NOPROCESS;
+ return procInfos;
}
public IProcessInfo[] parseListTasks(InputStreamReader reader) {

Back to the top