LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 01-19-2019, 09:36 AM   #1
anki123
LQ Newbie
 
Registered: Jan 2019
Posts: 1

Rep: Reputation: Disabled
API for current running process details like process name, process id, amount of memory used


Quote:
Originally Posted by sonuxp View Post
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

I'm new to linux can you please tell me the link of the documentation of API for to write a Linux C++ code to find all the current running process details like process name, process id, amount of memory used etc
 
Old 01-20-2019, 02:06 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
You can use the proc filesystem. Documented in the proc man page. Approximate workflow:

use getpid() to get process ID
read appropriate files under /proc/<process ID>

I even found a C++ example how to access /proc: http://blog.davidecoppola.com/2016/1...line-in-linux/. And another example getting some information from several processes.

To learn more about the proc filesystem, you may want to search for procfs.

I remember the pstat(2) system call in UNIX, but it seems to me that Linux doesn't have it.

Last edited by berndbausch; 01-20-2019 at 02:11 AM.
 
  


Reply



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
To know the amount of memory used as cache in aix nagendrar AIX 2 12-16-2009 05:59 AM
Is it possible to know the amount of memory used by a program before running it? Gamma_User Programming 2 06-14-2009 08:38 AM
Is it possible to know the amount of memory used by a program before running it? Gamma_User Programming 2 03-03-2009 02:14 PM
Make most amount of Linux users in least amount of time studpenguin General 24 02-02-2007 03:42 PM
LXer: Q&A with Joost: Content Details, Technology Used, Name Explained LXer Syndicated Linux News 0 01-19-2007 07:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:58 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
Open Source Consulting | Domain Registration