In the /proc filesystem there are PIDs for each process running. In the directory for each process there is a stat file. The contents look something like this:
Code:
4005 (httpd) S 4004 4004 4004 0 -1 320 348964 160119 44705 52629 152362
7396 10394 669 9 0 0 0 60487804 19304448 2647 4294967295 134512640
134790828 3221224128 3221223664 1075297966 0 0 4096 71329387 3222576587 0 0 17 0
In there is all the information that you need. The proc man page details what all the fields are for and the type information.
Hope this helps
Edit: chopped up the code segment to display better