How can I retrieve uptime under linux using C? (without using popen and/or /proc)
Thanks
Advertisement
Answer
Via top
or via uptime
, but I don’t know about any syscall, someone will for sure 🙂
uptime
should be rather easy to parse.
Just stumbled into this:
#include <sys/sysinfo.h> struct sysinfo info; sysinfo(&info); printf("Uptime = %ldn", info.uptime);