Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-07-2004, 06:05 AM   #1
LQ Newbie
Registered: Jun 2004
Posts: 2

Rep: Reputation: 0
Unhappy Process Enumeration with C++

hello ,everybody,

i am stuck.. i m new to Linux and know nothing abou it.....
i want to know following things with C++ program on Linux....

i would be gien list of
apache server cte... and i have to fetch the followings......

Process is runnin or not/???
Process related Info - memoru consumed..cpu uasage ..No of threads runnning..etc...

i am writting a C++ application plz give me related help...
i know three are linux command which gives hese info like PS but how to use them in C++ can i capture the out put of such commands ...or is there another way like we havein Windows platform, called WIN-API...
plzgive me C++ COde it would be a greatr help for me...
really expecfting some quick answers...i m really really really in hurry and badly stuck...

Old 06-07-2004, 12:22 PM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
popen() will let you execute a command and capture the output via a redirected pipe.

FILE *fd;
char cmdoutput[496]={'\0'};
fd=popen("ps -ef", "r");
                  /* cmdoutput  has a line of output */
         } else{
                if(feof(fd)) break;
                perror("Pipe processing error");
Old 06-08-2004, 02:16 AM   #3
LQ Newbie
Registered: Jun 2004
Posts: 2

Original Poster
Rep: Reputation: 0
sorry to bug u again but i m still facing the problem.i m very new to linux and programming . i fired the samplecode given by you and it returns the following result..


amit 18186 18185 0 11:47 pts/3 00:00:00 ps -ef

Program exited successfully with errcode (0)
Press the Enter key to close this terminal ...


even if i try changing the command it is not helping me i have fired ps -aux too but the result is the same...
i m confused.....
my inputs would be process name only and i have to find out everything about the process then...
CPU usgae
No of THreads Running
Memory Usage etc...

plz help me out.....

best regs


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 a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 08:26 AM
Linux boot up process Vs. Windows boot up process darkskull Linux - Software 7 12-30-2006 05:21 PM
how can i get the process id on exec a process antony_csf Linux - Software 1 06-17-2004 04:06 AM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 02:19 PM
problem with binding process and than execute another process chapa Programming 0 08-27-2003 04:47 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:01 PM.

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