summaryrefslogtreecommitdiffstats
path: root/btimed.c
diff options
context:
space:
mode:
Diffstat (limited to 'btimed.c')
-rw-r--r--btimed.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/btimed.c b/btimed.c
index 68a045a..83a5af6 100644
--- a/btimed.c
+++ b/btimed.c
@@ -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;
}