LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-29-2005, 12:54 AM   #1
balasquare@yahoo.com
LQ Newbie
 
Registered: Sep 2005
Posts: 3

Rep: Reputation: 0
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
 
Old 09-29-2005, 01:58 AM   #2
shazam75
Member
 
Registered: Oct 2004
Location: Australia, Brisbane
Distribution: Gentoo
Posts: 296

Rep: Reputation: 30
why dont you simple use the command:

pstree -pa

Regards
Shelton.
 
Old 09-29-2005, 05:33 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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?
 
Old 09-29-2005, 05:39 AM   #4
shazam75
Member
 
Registered: Oct 2004
Location: Australia, Brisbane
Distribution: Gentoo
Posts: 296

Rep: Reputation: 30
i suppose "pstree" is a c program LOL
 
Old 09-29-2005, 05:39 AM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use task_struct to get process information?? Pratik H Pandya Programming 2 09-15-2005 04:40 AM
get information when a process run?????? hungnt Linux - Newbie 6 07-16-2005 11:57 AM
process information application? YBA^[x] Slackware 6 01-13-2005 11:04 AM
New process w/o current parent? novaprime Programming 2 01-04-2005 10:06 PM
Finding information about the current shell atirya_yodha Linux - Newbie 3 03-18-2004 02:30 PM


All times are GMT -5. The time now is 09:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration