Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!jabberwock.shs.ohio-state.edu!reiner From: reiner@jabberwock.shs.ohio-state.edu (Reiner Wilhelms) Newsgroups: comp.unix.questions Subject: Process ID of a "Stranger" Keywords: PID, ps , getpid(2) Message-ID: <266@jabberwock.shs.ohio-state.edu> Date: 30 Aug 90 00:00:53 GMT Distribution: usa Organization: The Ohio State University, Division of Speech and Hearing Science Lines: 23 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