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?
1 Answer
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, ps or htop all use the /proc filesystem. You should check out their sources if you're having trouble with using it.
1 Comment
Luca Carlon
I don't know why but I really don't like it this way. Anyway, thanks!