Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2002-10-15 17:58:15 +0000
committerAlain Magloire2002-10-15 17:58:15 +0000
commit0440f4618e188fad46645e99e1a48afea0f05593 (patch)
tree502563df7984999e29f4a9c4b27662be0f850d39 /core/org.eclipse.cdt.core.solaris/src
parentd049b3c0ae6f99bde116650ea765e480ae15bdec (diff)
downloadorg.eclipse.cdt-0440f4618e188fad46645e99e1a48afea0f05593.tar.gz
org.eclipse.cdt-0440f4618e188fad46645e99e1a48afea0f05593.tar.xz
org.eclipse.cdt-0440f4618e188fad46645e99e1a48afea0f05593.zip
implement for solaris ProcessList, this is use to get
a list of pid to attach in the debugger.
Diffstat (limited to 'core/org.eclipse.cdt.core.solaris/src')
-rw-r--r--core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessInfo.java45
-rw-r--r--core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessList.java67
2 files changed, 112 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessInfo.java b/core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessInfo.java
new file mode 100644
index 00000000000..7455dbbbfb4
--- /dev/null
+++ b/core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessInfo.java
@@ -0,0 +1,45 @@
+package org.eclipse.cdt.internal.core.solaris;
+
+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.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessList.java b/core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessList.java
new file mode 100644
index 00000000000..6ad8c40c11e
--- /dev/null
+++ b/core/org.eclipse.cdt.core.solaris/src/org/eclipse/cdt/internal/core/solaris/ProcessList.java
@@ -0,0 +1,67 @@
+package org.eclipse.cdt.internal.core.solaris;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+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 ps;
+ BufferedReader psOutput;
+ String[] args = {"/usr/bin/ps", "-e", "-o", "pid,args"};
+
+ try {
+ ps = ProcessFactory.getFactory().exec(args);
+ psOutput = new BufferedReader(new InputStreamReader(ps.getInputStream()));
+ } catch(Exception e) {
+ return new IProcessInfo[0];
+ }
+
+ //Read the output and parse it into an array list
+ ArrayList procInfo = new ArrayList();
+
+ try {
+ String lastline;
+ while ((lastline = psOutput.readLine()) != null) {
+ //The format of the output should be
+ //PID space name
+
+ int index = lastline.indexOf(' ');
+ if (index != -1) {
+ String pidString = lastline.substring(0, index).trim();
+ try {
+ int pid = Integer.parseInt(pidString);
+ String arg = lastline.substring(index + 1);
+ procInfo.add(new ProcessInfo(pid, arg));
+ } catch (NumberFormatException e) {
+ }
+ }
+ }
+
+ } catch(Exception e) {
+ /* Ignore */
+ }
+
+ ps.destroy();
+ return (IProcessInfo [])procInfo.toArray(new IProcessInfo[procInfo.size()]);
+ }
+
+}

Back to the top