修改当前CPU使用率段错误
This commit is contained in:
parent
95fa9854a1
commit
62ede9286d
|
@ -24,6 +24,7 @@
|
|||
#include <cstring-extension.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <libkylog.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#define MEMINFO_FILE "/proc/meminfo"
|
||||
|
@ -283,10 +284,15 @@ static int _get_cpu_data(unsigned long *user, unsigned long *sys, unsigned long
|
|||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
*user = atol(list[1]);
|
||||
*sys = atol(list[3]);
|
||||
*idle = atol(list[4]);
|
||||
*iowait = atol(list[5]);
|
||||
klog_info("list1 = %s, list3 = %s, list4 = %s, list5 = %s\n", list[1], list[3], list[4], list[5]);
|
||||
if(list[1])
|
||||
*user = atol(list[1]);
|
||||
if(list[3])
|
||||
*sys = atol(list[3]);
|
||||
if(list[4])
|
||||
*idle = atol(list[4]);
|
||||
if(list[5])
|
||||
*iowait = atol(list[5]);
|
||||
free(list);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue