Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Inglis2002-10-07 20:02:58 +0000
committerDavid Inglis2002-10-07 20:02:58 +0000
commit6c738e9dcbc62c86caad748c91d46478c2023a86 (patch)
treeb87e359708dd3c3449de96543c3f8da39db44e22 /core/org.eclipse.cdt.core.qnx
parent0180598ed2ab21f1c4a29df450d99926f4ffd667 (diff)
downloadorg.eclipse.cdt-6c738e9dcbc62c86caad748c91d46478c2023a86.tar.gz
org.eclipse.cdt-6c738e9dcbc62c86caad748c91d46478c2023a86.tar.xz
org.eclipse.cdt-6c738e9dcbc62c86caad748c91d46478c2023a86.zip
added QNX processlist extension
Diffstat (limited to 'core/org.eclipse.cdt.core.qnx')
-rw-r--r--core/org.eclipse.cdt.core.qnx/.classpath3
-rw-r--r--core/org.eclipse.cdt.core.qnx/.cvsignore1
-rw-r--r--core/org.eclipse.cdt.core.qnx/fragment.xml7
-rw-r--r--core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessInfo.java45
-rw-r--r--core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessList.java130
5 files changed, 185 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.qnx/.classpath b/core/org.eclipse.cdt.core.qnx/.classpath
index b9421ac9ce..d317cd64b8 100644
--- a/core/org.eclipse.cdt.core.qnx/.classpath
+++ b/core/org.eclipse.cdt.core.qnx/.classpath
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
@@ -9,5 +10,5 @@
<classpathentry kind="src" path="/org.eclipse.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
- <classpathentry kind="output" path=""/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/core/org.eclipse.cdt.core.qnx/.cvsignore b/core/org.eclipse.cdt.core.qnx/.cvsignore
new file mode 100644
index 0000000000..ba077a4031
--- /dev/null
+++ b/core/org.eclipse.cdt.core.qnx/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/core/org.eclipse.cdt.core.qnx/fragment.xml b/core/org.eclipse.cdt.core.qnx/fragment.xml
index 3fa98872a3..d54c4e6d6f 100644
--- a/core/org.eclipse.cdt.core.qnx/fragment.xml
+++ b/core/org.eclipse.cdt.core.qnx/fragment.xml
@@ -8,7 +8,14 @@
plugin-version="1.0.0">
<runtime>
+ <library name="cdt_qnx.jar"/>
</runtime>
+ <extension
+ point="org.eclipse.cdt.core.ProcessList">
+ <processList
+ class="org.eclipse.cdt.internal.core.qnx.ProcessList">
+ </processList>
+ </extension>
</fragment>
diff --git a/core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessInfo.java b/core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessInfo.java
new file mode 100644
index 0000000000..a72e310e32
--- /dev/null
+++ b/core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessInfo.java
@@ -0,0 +1,45 @@
+package org.eclipse.cdt.internal.core.qnx;
+
+import org.eclipse.cdt.core.IProcessInfo;
+
+/**
+ * @author alain
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class ProcessInfo implements IProcessInfo {
+
+ int pid;
+ String name;
+
+ public ProcessInfo(String pidString, String name) {
+ try {
+ pid = Integer.parseInt(pidString);
+ } catch (NumberFormatException e) {
+ }
+ this.name = name;
+ }
+
+ public ProcessInfo(int pid, String name) {
+ this.pid = pid;
+ this.name = name;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.IProcessInfo#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.eclipse.cdt.core.IProcessInfo#getPid()
+ */
+ public int getPid() {
+ return pid;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessList.java b/core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessList.java
new file mode 100644
index 0000000000..87eae3fd31
--- /dev/null
+++ b/core/org.eclipse.cdt.core.qnx/src/org/eclipse/cdt/internal/core/qnx/ProcessList.java
@@ -0,0 +1,130 @@
+package org.eclipse.cdt.internal.core.qnx;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.IProcessInfo;
+import org.eclipse.cdt.core.IProcessList;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+
+/**
+ * Insert the type's description here.
+ * @see IProcessList
+ */
+public class ProcessList implements IProcessList {
+
+ ProcessInfo[] empty = new ProcessInfo[0];
+
+ public ProcessList() {
+ }
+
+ /**
+ * Insert the method's description here.
+ * @see IProcessList#getProcessList
+ */
+ public IProcessInfo [] getProcessList() {
+ Process pidin;
+ BufferedReader pidinOutput;
+ String[] args = {"pidin", "-fan" };
+
+ try {
+ pidin = ProcessFactory.getFactory().exec(args);
+ pidinOutput = new BufferedReader(new InputStreamReader(pidin.getInputStream()));
+ } catch(Exception e) {
+ return getProcessListPureJava();
+ }
+
+ //Read the output and parse it into an array list
+ ArrayList procInfo = new ArrayList();
+
+ String pidStr, nameStr, lastline;
+ try {
+ while((lastline = pidinOutput.readLine()) != null) {
+ //The format of the output should be
+ //PID a/slash/delimited/name
+
+ StringTokenizer tok = new StringTokenizer(lastline.trim());
+ pidStr = tok.nextToken();
+ if(pidStr == null || pidStr.charAt(0) < '0' || pidStr.charAt(0) > '9') {
+ continue;
+ }
+
+ nameStr = tok.nextToken();
+
+ int index = nameStr.lastIndexOf('/');
+ if(index != -1) {
+ nameStr = nameStr.substring(index + 1);
+ }
+
+ procInfo.add(new ProcessInfo(pidStr, nameStr));
+ }
+
+ pidin.destroy();
+ } catch(Exception e) {
+ /* Ignore */
+ } finally {
+ pidin.destroy();
+ }
+
+ return (IProcessInfo [])procInfo.toArray(new IProcessInfo[procInfo.size()]);
+ }
+
+ /**
+ * This is our current backup strategy for getting the pid list
+ * (reading /proc directly). Currently the exename is not implemented
+ * so the names will all show up as unknown, but at least you get a
+ * pid list.
+ */
+ private IProcessInfo [] getProcessListPureJava() {
+ File proc = new File("/proc");
+ File[] pidFiles = null;
+
+ // We are only interrested in the pid so filter the rest out.
+ try {
+ FilenameFilter filter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ boolean isPID = false;
+ try {
+ Integer.parseInt(name);
+ isPID = true;
+ } catch (NumberFormatException e) {
+ }
+ return isPID;
+ }
+ };
+ pidFiles = proc.listFiles(filter);
+ } catch (SecurityException e) {
+ }
+
+ ProcessInfo[] processInfo = empty;
+ if (pidFiles != null) {
+ processInfo = new ProcessInfo[pidFiles.length];
+ for (int i = 0; i < pidFiles.length; i++) {
+ File cmdLine = new File(pidFiles[i], "exename");
+ StringBuffer line = new StringBuffer();
+ try {
+ FileReader reader = new FileReader(cmdLine);
+ int c;
+ while ((c = reader.read()) > 0) {
+ line.append((char)c);
+ }
+ } catch (IOException e) {
+ }
+ String name = line.toString();
+ if (name.length() == 0) {
+ name = "Unknown";
+ }
+ processInfo[i] = new ProcessInfo(pidFiles[i].getName(), name);
+ }
+ } else {
+ pidFiles = new File[0];
+ }
+ return processInfo;
+ }
+}

Back to the top