Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
9 #include <sys/sysinfo.h>
23 m
= (uptime
- h
* 3600) / 60;
25 return bprintf("%dh %dm", h
, m
);
27 #elif defined(__OpenBSD__)
28 #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) != -1)
51 uptime
= now
- boottime
.tv_sec
;
53 fprintf(stderr
, "sysctl 'KERN_BOOTTIME': %s\n", strerror(errno
));
58 m
= (uptime
- h
* 3600) / 60;
60 return bprintf("%dh %dm", h
, m
);