Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
4 #include <sys/sysinfo.h>
6 #include <sys/sysctl.h>
27 struct timeval boottime
;
32 mib
[1] = KERN_BOOTTIME
;
34 size
= sizeof(boottime
);
36 if (sysctl(mib
, 2, &boottime
, &size
, NULL
, 0) != -1)
37 uptime
= now
- boottime
.tv_sec
;
42 m
= (uptime
- h
* 3600) / 60;
44 return bprintf("%dh %dm", h
, m
);