?
Solved

extracting information about the processes running from the /proc directory

Posted on 2003-03-29
5
Medium Priority
?
202 Views
Last Modified: 2010-04-21
I am writing a program to display the current processes running on the linux OS. I do'nt know how to access the current process information like the stat file, statm file cmdline file of the process currently running. Is there any system calls present to get these information?
0
Comment
Question by:omdon
4 Comments
 

Author Comment

by:omdon
ID: 8230610
if possible give the information on tracking a process on the /proc directory...
0
 

Accepted Solution

by:
keramati_h earned 100 total points
ID: 8233396
Hello,
You can use /proc directory
/proc/self is a directory that have information of current process. you can read these files for your purpose:
/proc/self/stat
/proc/self/statm
/proc/self/status
and so on...

Thanks
0
 

Expert Comment

by:rainerz
ID: 8339169
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>

int main()
{
struct rusage data;
getrusage( RUSAGE_SELF,&data);
/* now print the wanted fields */
};
this system call gives you a struct rusage, where you find most of the stat data.

            struct rusage
            {
                 struct timeval ru_utime; /* user time used */
                 struct timeval ru_stime; /* system time used */
                 long ru_maxrss;          /* maximum resident set size */
                 long ru_ixrss;      /* integral shared memory size */
                 long ru_idrss;      /* integral unshared data size */
                 long ru_isrss;      /* integral unshared stack size */
                 long ru_minflt;          /* page reclaims */
                 long ru_majflt;          /* page faults */
                 long ru_nswap;      /* swaps */
                 long ru_inblock;         /* block input operations */
                 long ru_oublock;         /* block output operations */
                 long ru_msgsnd;          /* messages sent */
                 long ru_msgrcv;          /* messages received */
                 long ru_nsignals;        /* signals received */
                 long ru_nvcsw;      /* voluntary context switches */
                 long ru_nivcsw;          /* involuntary context switches */
            };
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10225207
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: keramati_h {http:#8233396}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question