I'm implementing an alternative to top
, and thought that I should preallocate an appropriately sized buffer to hold the read contents of /proc/PID/stat
.
However, knowing that it's a pseudo filesystem where contents of files will be generated on-demand, will simply statting that file result in the kernel doing work to generate its contents, so that a file size is returned?