Wednesday, February 1, 2012

Power of Proc-8: Details of a process current status

Have you ever tried these without using gdb and ps in Linux ..
1. How many threads a process has ?
2. is any one tracing the process ?
3. what is current Process state ?

Here we go. Before going into details, The all commands are experimented on Linux version 2.6.32 x86_64 and RHEL61.

Proc file system provides all information about a process current state. These details can be seen by looking at the file "/proc/[pid]/status".
Most of these details provided here can also be seen in "ps" command output and also using gdb.

This information can be used for first investigation of the problem or they are useful in some cases.

Here I have chosen crond process (pid=1379) and looking at the file /proc/1379/status. Output is shown below and will discuss about entries in the output.

[root@192 ~]# cat /proc/1379/status
Name:   crond  
State:  S (sleeping)
Tgid:   1379
Pid:    1379
PPid:   1
TracerPid:      0
Uid:    0       0       0       0
Gid:    0       0       0       0
Utrace: 0
FDSize: 64
Groups:
VmPeak:   117208 kB
VmSize:   117176 kB
VmLck:         0 kB
VmHWM:      1368 kB
VmRSS:       184 kB
VmData:      900 kB
VmStk:       528 kB
VmExe:        56 kB
VmLib:      2400 kB
VmPTE:        60 kB
VmSwap:      544 kB
Threads:        1
SigQ:   0/30534
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000000014003
CapInh: 0000000000000000
CapPrm: ffffffffffffffff
CapEff: ffffffffffffffff
CapBnd: ffffffffffffffff
Cpus_allowed:   f
Cpus_allowed_list:      0-3
Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001
Mems_allowed_list:      0
voluntary_ctxt_switches:        266259
nonvoluntary_ctxt_switches:     9

Lets take few interesting entries from the above output.


-Name:     Process name
-State:      Current state of the process. S indicates process is sleeping.
-Pid:         Process Id
-PPid:       Parent process Id
-TracerPid:      Process ID of tracer process. Covering what is a tracer process, how to implement or write Trace program is out of scope for this post. But I will be covering that topic as well in future. Tha value '0' indicates that this process is not being traced.
-FDSize:   Number of file descriptors allocated for this process. Out of which , how many file descriptors that the process is used can be identified by the number of entries in  /proc/pid/fd/. For more details Refer this post Power of Proc-6
-Threads:  NUmber of threads that the current process has.

Apart from the above details, this output also contains details of memory usage, signal details (pending,ignored,blocking,caught) and few details about cpu allocation.

Hopefully you enjoyed reading this post. Please leave your comments.

Pin It
Related Posts Plugin for WordPress, Blogger...