LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   get info about a specific process (https://www.linuxquestions.org/questions/programming-9/get-info-about-a-specific-process-128020/)

hfawzy 12-22-2003 05:05 AM

get info about a specific process
 
Hello,
I want to get information about a specific process automatically. I can get these infos from the /proc/PID/status file. But my problem is that the process that I want to get its info could take no time to execute . If I have a program named foo, when I want to get its info, I use this command :

Code:

./foo | cat /proc/`/sbin/pidof foo`/status
BUT the program foo takes no time to execute. Consequently, when I try to search for its info, the directory /proc/`/sbin/pidof foo` is already removed.
So my question is : How can I pause the program foo, until I can get its info, then kill foo ?

Regards,
hfawzy

jim mcnamara 12-22-2003 11:08 AM

There is another file, wtmp, that is written if accounting is enabled.
It records process creation, deletion times, etc. Has the same format as utmp. The information is not lost.

See the man pages for getutent or utmp.

imsandy_007 01-30-2007 02:42 AM

get info of a process
 
i want a simple c code for pausing the process which doesnot use the kill command because i want to do some process programming but there is not much help available..
please help.

culin 01-30-2007 03:28 AM

for pausing u can use sleep() command ... sleep(1) sleeps for a second...and similarly for slee(2) and so on... bud don know it is recommanded to ur situation or not....

imsandy_007 01-31-2007 01:11 PM

well using the sleep() command is also a solution to the problem..

but i wanted to have a better approach in terms of programming, like for example using the process link list and using the task_struct to access the task and then setting the status field to pause..

i know the theory but i am unable to do the programming.

please reply.


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