LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to write a system call to display the process information? (https://www.linuxquestions.org/questions/programming-9/how-to-write-a-system-call-to-display-the-process-information-367814/)

balasquare@yahoo.com 09-28-2005 10:24 AM

How to write a system call to display the process information?
 
Hi,

How can I write a custom system call which lists the process information for a given process id?

I need to call this system call from my C program.

Is there any document describing the steps I need to carry out to carry out this. where can I find any working examples on the custom system calls?


thanks in advance.
Bala

kjordan 09-28-2005 11:01 AM

What kind of process information? Is there anything you need that you can't find in the files in /proc/<pid>?

balasquare@yahoo.com 09-28-2005 10:53 PM

Hi,

I am trying to get the following process information:

pid,
state of the process,
process owner,
parent_id,
sibling_id,
comm --> name of the program

etc..

How can I get this process information Printed in my C program.

Thanks,
Balaji

btmiller 09-30-2005 01:05 AM

All of this info except for siblings can be easily obtained by parsing the /proc/<pid>/status file. To get siblings you can just parse the output of ps and look for processes with the same ppid. This can be inefficient, so if you have to do it a lot you might want to construct a linked list of some sort and update it relatively infrequently (once every few seconds). The disadvantage is the info will be slightly out of date.


All times are GMT -5. The time now is 02:41 PM.