LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to get the current process information (http://www.linuxquestions.org/questions/programming-9/how-to-get-the-current-process-information-368017/)

balasquare@yahoo.com 09-28-2005 11:54 PM

How to get the current process information
 
Hi,

I am trying to develop a C program to print the current process information.

Where can I find some sample C programs to do this? Does any one has a sample C program which prints the current process information.

Thanks,
Bala

shazam75 09-29-2005 12:58 AM

why dont you simple use the command:

pstree -pa

Regards
Shelton.

Hko 09-29-2005 04:33 AM

Quote:

Originally posted by shazam75
why dont you simple use the command:

pstree -pa
Maybe because it can be a good way to learn C-programming for Linux?

shazam75 09-29-2005 04:39 AM

i suppose "pstree" is a c program LOL

Hko 09-29-2005 04:39 AM

Re: How to get the current process information
 
Quote:

Originally posted by balasquare@yahoo.com
I am trying to develop a C program to print the current process information.

Where can I find some sample C programs to do this? Does any one has a sample C program which prints the current process information.
The subdirectories of /proc that have numbers for a name, contain files and subdirectories that contain information about processes. The numbers are the PID's of the processes. /proc/self is a symlink to /proc/<pid>, so to find info on the process running your program, you can read the files and sub-dirs in/proc/self.

The meaning of the files/subdirs in /proc/<pid> (and a such /proc/self as well) can be found in "man 5 proc".


All times are GMT -5. The time now is 09:48 AM.