fake boot_time if no btime in /proc/stat

This commit is contained in:
Doug MacEachern 2007-11-09 01:27:32 +00:00
parent 8176b390fa
commit 29f25f22b7
1 changed files with 8 additions and 3 deletions

View File

@ -140,9 +140,14 @@ int sigar_os_open(sigar_t **sigar)
(*sigar)->pagesize++; (*sigar)->pagesize++;
} }
ptr = strstr(buffer, "\nbtime"); if ((ptr = strstr(buffer, "\nbtime"))) {
ptr = sigar_skip_token(ptr); ptr = sigar_skip_token(ptr);
(*sigar)->boot_time = sigar_strtoul(ptr); (*sigar)->boot_time = sigar_strtoul(ptr);
}
else {
/* should never happen */
(*sigar)->boot_time = time(NULL);
}
(*sigar)->ticks = sysconf(_SC_CLK_TCK); (*sigar)->ticks = sysconf(_SC_CLK_TCK);