18 lines
662 B
Diff
18 lines
662 B
Diff
--- top.c
|
|
+++ top.c
|
|
@@ -930,6 +930,14 @@
|
|
rewind(fp);
|
|
fflush(fp);
|
|
|
|
+ /* save the previous values of cpus[Cpu_tot](i.e. u_sav, s_sav, n_sav, i_sav,
|
|
+ * w_sav, x_sav, y_sav) to cpus[cpu_max] before any changes to cpus[], so these
|
|
+ * values are not overwritten when copying cpus[cpu_max] back to cpus[Cpu_tot]
|
|
+ * at the end of this function.
|
|
+ */
|
|
+ if (cpu_max != Cpu_tot)
|
|
+ memcpy(&cpus[cpu_max], &cpus[Cpu_tot], sizeof(CPU_t));
|
|
+
|
|
// first value the last slot with the cpu summary line
|
|
if (!fgets(buf, sizeof(buf), fp)) std_err("failed /proc/stat read");
|
|
cpus[cpu_max].x = 0; // FIXME: can't tell by kernel version number
|