#!/bin/bash
# script to read /proc/*/stat
pid="${1:-self}"
set $(</proc/$pid/stat)
column -t -s "|" <<__EOF__ 
FIELD | VALUE | DESC
pid | ${1} | The process ID
comm | ${2} | The  filename of the executable
state | ${3}  | state
ppid | ${4} | The PID of the parent
pgrp | ${5} | The process group ID of the process
session | ${6} | The session ID of the process
tty_nr | ${7} | The tty the process uses
tpgid | ${8} | The  process group ID of the process which currently owns the tty
flags | ${9} | The kernel flags word of the process
minflt | ${10} | The number of minor faults
cminflt | ${11} | The  number of minor faults of waited-for children
majflt | ${12} | The number of major faults required loading from disk
cmajflt | ${13} | The  number of major faults of waited-for children
utime | ${14} | Time this process has been scheduled in user mode (jiffies)
stime | ${15} | Time this process has been schduuled in kernel mode (jiffies)
cutime | ${16} | Waited-for children time in user mode (jiffies)
cstime | ${17} | Waited-for children time in kernel mode (jiffies)
priority | ${18} | The  standard  nice  value,  plus  fifteen
nice | ${19} | The nice value ranges from 19 (nicest) to -19
0 | ${20} | Hard coded to 0 as a placeholder for a removed field
itrealvalue | ${21} | Time before next SIGALRM is sent by a time (jiffies)
starttime | ${22} | Kernel start time as jiffies since last system boot
vsize | ${23} | Virtual memory size in bytes
rss | ${24} | Resident Set Size
rlim | ${25} | Current limit in bytes on the rss of the process
startcode | ${26} | The address above which program text can run
endcode | ${27} | The address below which program text can run
startstack | ${28} | The address of the start of the stack
kstkesp | ${29} | The current value of esp (stack pointer)
kstkeip | ${30} | The current EIP (instruction pointer)
signal | ${31} | The bitmap of pending signals
blocked | ${32} | The bitmap of blocked signals
sigignore | ${33} | The bitmap of ignored signals
sigcatch | ${34} | The bitmap of caught signals
wchan | ${35} | Process wait channel
nswap | ${36} | Number of pages swapped (not maintained)
cnswap | ${37} | Cumulative nswap for child processes (not maintained)
exit_signal | ${38} | Signal to be sent to parent when we die
processor | ${39} | CPU number last executed on
rt_priority | ${40} | (> kernel 2.5.19) Real-time scheduling priority
policy | ${41} | (> kernel 2.5.19)
__EOF__
