Skip to content

Commit 2aa4209

Browse files
committed
ajee10x#3 Do not fail on parsing of ps output
1 parent 04405ff commit 2aa4209

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/ltm/ProcessesPanel.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,27 @@ private void refreshProcesses() {
211211
tableModel.addRow(processInfo);
212212
}
213213

214-
// Calculate CPU and Memory percentages
215-
double cpuPercentage = calculateCpuPercentage(processData) * 100;
216-
double memoryPercentage = calculateMemoryPercentage(processData) * 100;
217-
218-
// Update the CPU and Memory progress bars
219-
cpuProgressBar.setValue((int) cpuPercentage);
220-
cpuProgressBar.setString(String.format("CPU: %.0f%%", cpuPercentage));
221-
memoryProgressBar.setValue((int) memoryPercentage);
222-
memoryProgressBar.setString(String.format("Memory: %.0f%%", memoryPercentage));
214+
try {
215+
// Calculate CPU and Memory percentages
216+
double cpuPercentage = calculateCpuPercentage(processData) * 100;
217+
double memoryPercentage = calculateMemoryPercentage(processData) * 100;
218+
219+
// Update the CPU and Memory progress bars
220+
cpuProgressBar.setValue((int) cpuPercentage);
221+
cpuProgressBar.setString(String.format("CPU: %.0f%%", cpuPercentage));
222+
memoryProgressBar.setValue((int) memoryPercentage);
223+
memoryProgressBar.setString(String.format("Memory: %.0f%%", memoryPercentage));
224+
} catch (Exception e) {
225+
e.printStackTrace();
226+
}
223227

224228
// Wait for the process to complete
225229
int exitCode = process.waitFor();
226230
if (exitCode != 0) {
227231
// Handle any errors if necessary
228232
System.err.println("Error executing script. Exit code: " + exitCode);
229233
}
230-
} catch (IOException | InterruptedException e) {
234+
} catch (Exception e) {
231235
e.printStackTrace();
232236
}
233237
}

0 commit comments

Comments
 (0)