Friday, 11 September 2009

Explore process Information in unix

Each process has an entry in the /proc filesystem identified by its PID. The following are the important files in /proc directory:
  • pid/cmdline contains the command that was used to start the process (using null characters to separate the arguments).
  • /proc/pid/cwd contains a link to the current working directory of the process.
  • /proc/pid/environ contains a list of the environment variables that the process has available.
  • /proc/pid/exe contains a link to the program that is running in the process.
  • /proc/pid/fd/ is a directory containing a link to each of the files that the process has open.
  • /proc/pid/mem contains the memory contents of the process.
  • /proc/pid/stat contains process status information.
  • /proc/pid/statm contains process memory usage information. 
  • /proc/pid/lwp contains the threads running in the process with the process id

Commands :
ls -l /proc/pid/fd | wc -l
ls -l /proc/pid/lwp | wc -l

No comments: