diff options
Diffstat (limited to 'btimed.c')
-rw-r--r-- | btimed.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -112,9 +112,22 @@ get_btime(void) { unsigned int btime = 0; long hertz = sysconf(_SC_CLK_TCK); - struct tms tms; - btime = time(0) - (times(&tms) / hertz); + btime = time(0); + + if (access("/proc/uptime", F_OK | R_OK) == 0) { + FILE *proc_uptime; + unsigned long upsec = 0; + proc_uptime = fopen("/proc/uptime", "r"); + fscanf(proc_uptime, "%lu.%*u %*u.%*u\n", &upsec); + fclose(proc_uptime); + + btime -= upsec; + } else { + struct tms tms; + + btime -= (times(&tms) / hertz); + } btime = btime - (btime % 5) + 5; return btime; } |