Is There any API in linux to know process ID and it's status
Hai All,
I just need an API to know a process ID and it's status,whether it is alive or not. Any help would be appreciated greatly. Regards, -Siva. |
In what language ?
|
hai,
In 'C' Language i need an API to know about process ID and it's status. Thanks for ur quick response. Regards, -Siva. |
Maybe the command ps axu will be sufficient for your needs?
|
You may find it easier to get the information you want by opening and reading the "file" /proc/self/status
You can get a sample of the format and some of the available information by typing Code:
head -n 25 /proc/self/status The Linux kernel creates the information in that format as you read /proc/self/status. It is not like an ordinary file with the information sitting around waiting to be read. |
to w1k0: Probably, however "ps" is a command line (shell) API, not C.
I would suggest to travel the /proc directory in C to find out what processes are alive. Be aware though that what you'll find there doesn't represent an API, might be missing if /proc is not mounted, might change from a version to another and from a distribution to another. To check if a process is still alive while knowing its pid, you can use the kill system call with 0 as second parameter. |
Quote:
|
All times are GMT -5. The time now is 03:51 PM. |