[SIGAR-129] prevent possible wrapping

This commit is contained in:
Doug MacEachern 2008-12-10 21:51:53 +00:00
parent 8537ee876c
commit 3c0541888f
1 changed files with 3 additions and 0 deletions

View File

@ -156,6 +156,9 @@ SIGAR_DECLARE(int) sigar_proc_cpu_get(sigar_t *sigar, sigar_pid_t pid,
total_diff = proccpu->total - otime; total_diff = proccpu->total - otime;
proccpu->percent = total_diff / (double)time_diff; proccpu->percent = total_diff / (double)time_diff;
if (proccpu->percent > 1.0) {
proccpu->percent = 1.0;
}
return SIGAR_OK; return SIGAR_OK;
} }