Getting Linux process status from /proc
Linux /proc file system contains lots of information about the system and all running processes.
This article discusses one of the main files /proc/<pid>/stat which gives information about current running process.
I could not find good documentation for this file.
This article is written after some search on the network and looking at the source.
the stat file is an ascii file with one line of numbers and characters.
Fields are seperated with spaces.
The fields are as follows:
2. Executable name (usually given in parathesis)
3. state (R - running, S - sleeping, D - uninterruptible wait, Z - zombie, T - traced or stopped)
4. effective user id
5. effective group id
6. Parrend pid
7. pgrp of the process
8. Session id of the process
9. tty used
10. tpgid (I could not find documentation for this field meaning)
11. flags of process (could not find documentation for flags meaning)
12. Number of minor faults
13. Number of minor faults with childs
14. Number of major faults
15. Number of major faults with childs
16. Usermode jiffies
17. Kernel mode jiffies
18. Usermode jiffies with childs
19. Kernel mode jiffies with childs
20. Process next timeslice
21. Standard nice value plus 15
22. Time in jiffies of next timeout
23. Time before next SIGALRM is sent
24. Time the process started after system bot
25. Virtual memory size
26. Resident set size
27. Current limit in bytes on resident set size
28. Start address of code
29. End address of code
30. Stack address
31. Value of ESP
32. Value of EIP
33. Bitmap of pending signals
34. Bitmap of blocked signals
35. Bitmap of ignomed signals
36. Bitmap of catched signals
37. Could not find documentation for this field
39. scheduler (Could not find documentation for meaning)
40. scheduler priority