if (proc == null) {
Map m = ss.getShellMap();
Iterator it = m.entrySet().iterator();
while (it.hasNext()) {
Map.Entry ent = (Map.Entry) it.next();
ShellImpl shel = (ShellImpl) ent.getValue();
Map procs = shel.getProcesses();
proc = (Process) procs.get(outproc);
if (proc != null) break;
}
if (proc == null) {
error("No process for id: " + outproc);
return;
}
}
Object outb = proc.getOutputBuffer();
pout.println("Out buffer: " + outb + " [" + (outb == null ? "" : outb.getClass().getName()) + "]");
if (outb instanceof BufferImpl) {
List ls = ((BufferImpl) outb).getBufferCopy();
pout.println("\nContent: ");
pout.println(ls);
}
pout.flush();
return;
}
if(fullThreadDump) {
Set allTraces = Thread.getAllStackTraces().entrySet();
Iterator it = allTraces.iterator();
while(it.hasNext()) {
Map.Entry ent = (Map.Entry) it.next();
Thread key = (Thread) ent.getKey();
StackTraceElement [] traces = (StackTraceElement []) ent.getValue();
boolean netlight = false;
boolean plain = false;
boolean highlight = key.getState() != Thread.State.BLOCKED && key.getState() != Thread.State.TIMED_WAITING && key.getState() != Thread.State.WAITING;
if(highlight && traces.length > 0 &&
(("java.net.PlainSocketImpl".equals(traces[0].getClassName())
&& "socketAccept".equals(traces[0].getMethodName()))
|| ("java.net.SocketInputStream".equals(traces[0].getClassName())
&& "socketRead0".equals(traces[0].getMethodName())))
) {
netlight = true;
}
if(netlight) {
pout.print("\u001B[0;36m");
} else if(traces.length == 0) {
highlight = true;
pout.print("\u001B[0;31m");
} else if(highlight) {
plain = true;
pout.print("\u001B[1;33m");
}
pout.println(ent.getKey());
if(plain) {
pout.print("\u001B[0m\u001B[0;33m");
}
for(int i=0; i<traces.length; i++) {
pout.println(" " + traces[i]);
}
if(highlight)
pout.print("\u001B[0m");
}
pout.flush();
return;
}
if (order != null) {
try {
comptor = new TableComparator(order, (alles ? COLS_LONG : COLS_SHORT));
rows = new TreeSet(comptor);
} catch (Exception ex) {
error(ex.getMessage());
return;
}
}
//print("Processes: ");
// Let's list all info for all processes first
/*
Map m = ((ShellImpl) getShell()).getProcesses();
Iterator it = m.entrySet().iterator();
print("pID\tTime\tActive\tDone\tsessID\tType\tCmd\tErr");
while (it.hasNext()) {
Map.Entry me = (Map.Entry) it.next();
//log.debug("Key: " + me.getKey());
Process p = (Process) me.getValue();
print(p.getID() + "\t" +
elapsedTime(p.getStartTime()) + "\t" +
!p.isFinished() + "\t" +
p.canDispose() + "\t" +
getShell().getSessionID() + "\t" +
p.getClass().getName() + "\t" +
p.getCommandLine() + "\t" +
p.getThrowable());
}
*/
//print("Sessions:");
int idlen = longForm ? 40 : 10;
if (alles) {
fmt = new LineFormat(new int[]{idlen, idlen, 8, 8, 8, 5, 8, 7, 15, 3}, new String[]{"l", "l", "l", "l", "l", "l", "l", "l", "l"}, new int[]{0, 2, 2, 2, 2, 2, 2, 2, 2, 2});
print(fmt.print(COLS_LONG), 0);
} else {
fmt = new LineFormat(new int[]{idlen, idlen, 8, 8, 8, 3}, new String[]{"l", "l", "l", "l", "l", "l"}, new int[]{0, 2, 2, 2, 2, 2});
print(fmt.print(COLS_SHORT), 0);
}
//print("\n");
Iterator it = null;
Map procMap = null;
if (xall) {
procMap = ((SystemShellImpl) ((ShellImpl) getShell()).getSystemShell()).getShellMap();
//it = m.entrySet().iterator();
} else {
procMap = new HashMap();
procMap.put("0", getShell());
//it = m.entrySet().iterator();
}
HashSet singles = new HashSet();
// prepare hierarchies
it = procMap.entrySet().iterator();
while(it.hasNext()) {
Map.Entry ent = (Map.Entry)it.next();
ShellImpl shel = (ShellImpl) ent.getValue();
singles.add(shel);
Map pcs = shel.getProcesses();
Iterator it2 = pcs.entrySet().iterator();
while (it2.hasNext()) {
Map.Entry me2 = (Map.Entry) it2.next();
//log.debug("Key: " + me.getKey());
if ("0".equals(me2.getKey())) continue;
Process p = (Process) me2.getValue();
if(p.getParent() != null) {
List childls = (List) parentMap.get(p.getParent().getID());
if(childls == null) {
childls = new LinkedList();
parentMap.put(p.getParent().getID(), childls);
}
childls.add(p);
} else {
List childls = (List) parentMap.get(shel.getSessionID());
if(childls == null) {
childls = new LinkedList();
parentMap.put(shel.getSessionID(), childls);
}
childls.add(p);
}
}
}
it = singles.iterator();
while (it.hasNext()) {
ShellImpl shi = (ShellImpl) it.next();
outputProcess(shi, null, 0, idleShells);
}