You need the source code for the top and find the connection between top and / proc / directory in linux

I need the source code for the top, which I also could not find, I wanted to get a little more information about what exactly the / proc directory contains. I saw that it has folders with folders marked 1, 2, 3 4, .... and these folders seem to have a sequential set of files. I was wondering if these are directories for processes currently running on the machine.

I also wanted to know exactly how TOP is associated with this folder, because I was told that processes are tracked by TOP, by extracting data from these directories. I would like to know which file exactly TOP gets CPU usage of a specific process from the directory. If this is too complicated, it would be great if you could just tell me a piece of code where I could understand it!

Thanks for your help Shouvik

+3
source share
2 answers

top is part of procps , and yes, these numbers are process identifiers.

+1
source

Source: https://habr.com/ru/post/1757329/


All Articles