It happens sometimes that I need to retrieve some system data like CPU usage, process information etc.. which I commonly find in /proc/…. What I do from C/C++ is to read the correct file in /proc/…, parse it and get the information. This is quite bothering and somehow to be kernel version dependent. Is this the correct way to go?
Share
Unfortunately, the Linux kernel doesn’t offer any system calls which can be used to retrieve the kind of system information that’s exposed via
/proc. Your best bet in that case is to keep using that file system.If it makes you feel any better, all the tools like
top,psorhtopall use the/procfilesystem. You should check out their sources if you’re having trouble with using it.