1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-22 15:53:58 +02:00

patch for defect 147531

This commit is contained in:
David McKnight 2006-06-22 20:35:06 +00:00
parent e896d33266
commit cdf07cd4b3
4 changed files with 50 additions and 17 deletions

View file

@ -197,7 +197,7 @@ public class UniversalProcessMiner extends Miner implements IUniversalProcessDat
{ {
try try
{ {
HostProcessFilterImpl pfs = new HostProcessFilterImpl(subject.getSource()); HostProcessFilterImpl pfs = new HostProcessFilterImpl(subject.getSource(), true);
lookupProcesses(pfs, subject); lookupProcesses(pfs, subject);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -49,22 +49,24 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable, ISy
protected boolean anystatus; protected boolean anystatus;
protected String status; protected String status;
protected HashMap states; protected HashMap states;
protected boolean _resolveVariables;
/** /**
* Constructor to use when there is no existing filter string. * Constructor to use when there is no existing filter string.
*/ */
public HostProcessFilterImpl() public HostProcessFilterImpl()
{ {
name = ALL; _resolveVariables = false;
username = ALL; init();
gid = ALL; }
ppid = ALL;
pid = ALL; /**
minVM = 0; * Constructor to use when there is no existing filter string.
maxVM = -1; */
anystatus = true; public HostProcessFilterImpl(boolean resolveVariables)
initStates(); {
status = ""; _resolveVariables = resolveVariables;
init();
} }
protected void initStates() protected void initStates()
@ -80,6 +82,35 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable, ISy
* Constructor to use when filter string already exists. * Constructor to use when filter string already exists.
*/ */
public HostProcessFilterImpl(String input) public HostProcessFilterImpl(String input)
{
_resolveVariables = false;
initInput(input);
}
/**
* Constructor to use when filter string already exists.
*/
public HostProcessFilterImpl(String input, boolean resolveVariables)
{
_resolveVariables = resolveVariables;
initInput(input);
}
protected void init()
{
name = ALL;
username = ALL;
gid = ALL;
ppid = ALL;
pid = ALL;
minVM = 0;
maxVM = -1;
anystatus = true;
initStates();
status = "";
}
protected void initInput(String input)
{ {
anystatus = true; anystatus = true;
StringTokenizer tz = new StringTokenizer(input, "|"); StringTokenizer tz = new StringTokenizer(input, "|");
@ -178,7 +209,6 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable, ISy
} }
} }
public HashMap getStates() public HashMap getStates()
{ {
return states; return states;
@ -197,11 +227,11 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable, ISy
*/ */
public String getUsername() public String getUsername()
{ {
if (username.equals("${user.id}")) if (_resolveVariables && username.equals("${user.id}"))
{ {
return System.getProperty("user.name"); return System.getProperty("user.name");
} }
return username; else return username;
} }
/** /**
@ -387,6 +417,9 @@ public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable, ISy
String state = tokens[PROCESS_ATTRIBUTES_INDEX_STATUS].trim(); String state = tokens[PROCESS_ATTRIBUTES_INDEX_STATUS].trim();
if (!satisfiesState(state)) return false; if (!satisfiesState(state)) return false;
if (getUsername().equals("${user.id}"))
matcher = new NamePatternMatcher(ALL, true, false);
else
matcher = new NamePatternMatcher(getUsername(), true, false); matcher = new NamePatternMatcher(getUsername(), true, false);
if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_USERNAME])) return false; if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_USERNAME])) return false;
matcher = new NamePatternMatcher(ppid, true, false); matcher = new NamePatternMatcher(ppid, true, false);

View file

@ -180,7 +180,7 @@ public class UniversalAIXProcessHandler implements ProcessHandler, ISystemProces
// after the kill command is executed, the process might have changed // after the kill command is executed, the process might have changed
// attributes, or might be gone, so requery // attributes, or might be gone, so requery
HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); HostProcessFilterImpl rpfs = new HostProcessFilterImpl(true);
rpfs.setPid("" + process.getPid()); rpfs.setPid("" + process.getPid());
SortedSet results = lookupProcesses(rpfs); SortedSet results = lookupProcesses(rpfs);
if (results == null || results.size() == 0) return null; if (results == null || results.size() == 0) return null;

View file

@ -64,7 +64,7 @@ public class UniversalLinuxProcessHandler implements ProcessHandler, IServiceCon
// after the kill command is executed, the process might have changed // after the kill command is executed, the process might have changed
// attributes, or might be gone, so requery // attributes, or might be gone, so requery
HostProcessFilterImpl rpfs = new HostProcessFilterImpl(); HostProcessFilterImpl rpfs = new HostProcessFilterImpl(true);
rpfs.setPid("" + process.getPid()); rpfs.setPid("" + process.getPid());
SortedSet results = lookupProcesses(rpfs); SortedSet results = lookupProcesses(rpfs);
if (results == null || results.size() == 0) return null; if (results == null || results.size() == 0) return null;