Avoid a division by zero

This commit is contained in:
Pierre Pronchery 2009-12-23 15:09:13 +00:00
parent 6ef48f7136
commit 75feb4d76c

View File

@ -130,7 +130,7 @@ static gboolean _on_timeout(gpointer data)
used = cpu_time[CP_USER] + cpu_time[CP_SYS] + cpu_time[CP_NICE]
+ cpu_time[CP_INTR];
total = used + cpu_time[CP_IDLE];
if(cpu->used == 0)
if(cpu->used == 0 || total == cpu->total)
value = 0;
else
value = 100 * (used - cpu->used) / (total - cpu->total);