?
Solved

extracting information about the processes running from the /proc directory

Posted on 2003-03-29
5
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

762 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