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 processes...like textpad 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 ..so plz give me related help... i know three are linux command which gives hese info like PS but how to use them in C++ code...how 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... regs Ammit |
popen() will let you execute a command and capture the output via a redirected pipe.
Code:
FILE *fd; |
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..
OUTPUT *********************************************************** EXECUTING: /home/amit/Projects/Try/src/try ---------------------------------------------- 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... like CPU usgae No of THreads Running Memory Usage etc... plz help me out..... best regs Ammit |
All times are GMT -5. The time now is 10:25 PM. |