Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
12 m
= (uptime
- h
* 3600) / 60;
14 return bprintf("%dh %dm", h
, m
);
17 #if defined(__linux__)
18 #include <sys/sysinfo.h>
29 return format(uptime
);
31 #elif defined(__OpenBSD__)
32 #include <sys/sysctl.h>
41 struct timeval boottime
;
46 mib
[1] = KERN_BOOTTIME
;
48 size
= sizeof(boottime
);
50 if (sysctl(mib
, 2, &boottime
, &size
, NULL
, 0) < 0) {
51 warn("sysctl 'KERN_BOOTTIME':");
55 uptime
= now
- boottime
.tv_sec
;
57 return format(uptime
);