Process ID of a "Stranger"
Reiner Wilhelms
reiner at jabberwock.shs.ohio-state.edu
Thu Aug 30 10:00:53 AEST 1990
It is rather easy to obtain the process Id of a process via the system
call getpid(), and of the parent process via getppid().
However, how can I obtain the process id of a "stranger": some other
process, running on the same machine, if I just know its name?
Of course, it is possible to call ps, and then search for the name in
its output. I wonder if there is any system call or ugly trick which
does a simpler job, like:
{
int pid,errorcode;
....
errorcode = pid_by_name("Stranger",&pid);
if (errorcode == THERE_IS_NO_ONE_WITH_THAT_NAME)
sprintf(stderr,"Stranger is not running\n");
....
}
Is there something like pid_by_name() in Unix?
Or, to put it different, what does ps do?
Thank you for any hint.
Reiner
More information about the Comp.unix.questions
mailing list