handle processes that may have gone away

This commit is contained in:
Doug MacEachern committed 2009-02-06 13:45:44 -08:00
1 parent 4c441a3ee2
commit be5f4930a7
1 file changed
+6 -1
@@ -83,7 +83,12 @@ public class Top {
String cpuPerc = "?"; String cpuPerc = "?";
List info = Ps.getInfo(sigar, pid); List info;
try {
info = Ps.getInfo(sigar, pid);
} catch (SigarException e) {
continue; //process may have gone away
}
try { try {
ProcCpu cpu = sigar.getProcCpu(pid); ProcCpu cpu = sigar.getProcCpu(pid);
cpuPerc = CpuPerc.format(cpu.getPercent()); cpuPerc = CpuPerc.format(cpu.getPercent());