mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +02:00
Bug 158295 - Initial fixed process lists for Mac OS X
This commit is contained in:
parent
a90a2fbe6d
commit
c5f7fa5afd
1 changed files with 11 additions and 14 deletions
|
@ -52,18 +52,16 @@ public class UniversalMacOSXProcessHandler implements ProcessHandler {
|
||||||
*/
|
*/
|
||||||
public SortedSet lookupProcesses(IHostProcessFilter rpfs) throws Exception {
|
public SortedSet lookupProcesses(IHostProcessFilter rpfs) throws Exception {
|
||||||
SortedSet results = new TreeSet(new ProcessComparator());
|
SortedSet results = new TreeSet(new ProcessComparator());
|
||||||
|
// Using -A is problematic - the command never returns! Using -a for now.
|
||||||
// create the remote command with the Mac OS X specific attributes
|
String command = "/bin/ps -awwo pid,ucomm,state,ppid,uid,user,gid,vsz,rss";
|
||||||
String cmdLine = "/bin/ps -A -o 'pid ucomm state ppid uid user gid vsz rss'";
|
Process ps = Runtime.getRuntime().exec(command);
|
||||||
// run the command and get output
|
|
||||||
Process ps = Runtime.getRuntime().exec(cmdLine);
|
|
||||||
InputStreamReader isr = new InputStreamReader(ps.getInputStream());
|
InputStreamReader isr = new InputStreamReader(ps.getInputStream());
|
||||||
BufferedReader reader = new BufferedReader(isr);
|
BufferedReader reader = new BufferedReader(isr);
|
||||||
String nextLine = reader.readLine(); // Header line
|
String line = reader.readLine(); // Header line
|
||||||
nextLine = reader.readLine();
|
line = reader.readLine();
|
||||||
while (nextLine != null) {
|
while (line != null) {
|
||||||
// Input line looks like "pid ucomm state ppid uid user gid vsz rss"
|
// Input line looks like "pid ucomm state ppid uid user gid vsz rss"
|
||||||
String[] words = nextLine.split("\\s+");
|
String[] words = line.trim().split("\\s+");
|
||||||
UniversalServerProcessImpl usp = new UniversalServerProcessImpl();
|
UniversalServerProcessImpl usp = new UniversalServerProcessImpl();
|
||||||
usp.setPid(words[0]);
|
usp.setPid(words[0]);
|
||||||
usp.setName(words[1]);
|
usp.setName(words[1]);
|
||||||
|
@ -79,11 +77,10 @@ public class UniversalMacOSXProcessHandler implements ProcessHandler {
|
||||||
if (rpfs.allows(usp.getAllProperties())) {
|
if (rpfs.allows(usp.getAllProperties())) {
|
||||||
results.add(usp);
|
results.add(usp);
|
||||||
}
|
}
|
||||||
nextLine = reader.readLine();
|
line = reader.readLine();
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
isr.close();
|
isr.close();
|
||||||
if (results.size() == 0) return null;
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +115,10 @@ public class UniversalMacOSXProcessHandler implements ProcessHandler {
|
||||||
* the ps listing on Mac OS X.
|
* the ps listing on Mac OS X.
|
||||||
*/
|
*/
|
||||||
protected String convertToStateCode(String state) {
|
protected String convertToStateCode(String state) {
|
||||||
String key = state.substring(0, 0);
|
String key = state.substring(0, 1);
|
||||||
String stateCode = (String) stateMap.get(key);
|
String stateCode = (String) stateMap.get(key);
|
||||||
if (stateCode == null) {
|
if (stateCode == null) {
|
||||||
stateCode = "";
|
stateCode = Character.toString(ISystemProcessRemoteConstants.STATE_RUNNING);
|
||||||
}
|
}
|
||||||
return stateCode;
|
return stateCode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue