LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-15-2008, 06:53 AM   #1
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Rep: Reputation: 16
How do I find the process details from the C code


I need to write a Linux C++ code to find all the current running process details like process name, process id, amount of memory used etc. Something like ps -ef or top output. Is there any API to get these details. Please help.

Thanks in advance.
 
Old 07-15-2008, 08:46 AM   #2
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by Manjunath1847 View Post
I need to write a Linux C++ code to find all the current running process details like process name, process id, amount of memory used etc. Something like ps -ef or top output. Is there any API to get these details. Please help.

Thanks in advance.
Current process information is available in /proc/self directory. Open it and see what you can get there.
 
Old 07-15-2008, 09:06 AM   #3
sonuxp
LQ Newbie
 
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by ErV View Post
Current process information is available in /proc/self directory. Open it and see what you can get there.
Ya unix API's exist for them. Even ps at the backend uses them.
U can refer to the book "Advanced Programming in unix environment" from Richard Stevens
 
Old 07-18-2008, 06:45 AM   #4
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Original Poster
Rep: Reputation: 16
From strace on ps and top, I found that these commads are finding the all process related details from /proc directory, which contain one director for each of the running process with process id as the directoy name. Inside each of this directory we can get all the details like process name, memory used, status etc...
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
which file stores the process details babu198649 Linux - Newbie 5 11-05-2007 12:41 PM
Where can I find details on LVM strip. Tahir Saleh Linux - Newbie 3 10-24-2007 07:18 AM
How to find the details of NIC karamkumar Ubuntu 5 05-16-2007 11:39 PM
where can i find details of blocked emails karen.pertierra Linux - Security 1 02-22-2007 02:46 PM
Getting a Process Details grub Programming 4 05-28-2003 04:02 AM


All times are GMT -5. The time now is 10:30 PM.

Main Menu
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