Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proccess-ID's and names

Status
Not open for further replies.

ArnoMantwill

Programmer
May 17, 2001
7
DE
Does anyone know how to get in Unix a list of the running procces-ID's and names in a C program like "ps" does?
I have searched a lot but found nothing!
 
I don't know, but You can always execute a "ps" changing its standard output.
 
Hi,

You can get a process's id by calling getpid() from
inside it.

#include <sys/types.h>
#include <unistd.h>

pid_t proc_id = getpid();

for the process's parent id ,call getppid()

pid_t parent_proc_id = getppid();

I dont know how to list all process ids and names
from a process.

abp :-O
 
Hi folks!
I've found the source code of &quot;ps&quot; at Debian. But it's quite complicated for simple use!
I think, I will use &quot;ps&quot; and changing its standard output like mentioned by Kenrae.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top