Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
is there a function or system call in C which I can use to find Process ID of some other process?

Say, in process A I want to find the process ID of process B? Is there some function for this similar to getpid()?
Posted

1 solution

I don't know such function. But you may write your own by listing and parsing the information from the /proc/[pid] entries in the proc file system (see man 5 proc[^]).

Another solution would be execution of the ps command with the popen() function and parsing the output for the name of the other process.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900