LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-28-2005, 10:24 AM   #1
balasquare@yahoo.com
LQ Newbie
 
Registered: Sep 2005
Posts: 3

Rep: Reputation: 0
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
 
Old 09-28-2005, 11:01 AM   #2
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
What kind of process information? Is there anything you need that you can't find in the files in /proc/<pid>?
 
Old 09-28-2005, 10:53 PM   #3
balasquare@yahoo.com
LQ Newbie
 
Registered: Sep 2005
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 09-30-2005, 01:05 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,066

Rep: Reputation: 295Reputation: 295Reputation: 295
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.
 
  


Reply


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
write system call basics.... bisDude Programming 6 11-04-2005 06:48 PM
When does process swap happen in a system call? oldfogie Programming 3 05-03-2005 07:35 PM
is there a system call to send process to run in the background? feetyouwell Programming 4 10-01-2004 04:58 AM
difficulties with large files and system call read/write jwstric2 Programming 2 08-22-2004 11:42 PM
Changing Process Priority in Linux w/ System Call sptchamp Programming 2 07-21-2004 09:58 AM


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

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