I am running two instances of a program called
SMU, hence there will be two separate processes with the same name
SMU. And each
SMU process will create one (can be more than 1) child process, hence now there will be 4 process with the same process name as shown below (where 22313, 23835 are parent processes of two different instances).
22313 pts/10 00:35:00 SMU 22314 pts/10 00:35:06 SMU 23835 pts/6 00:25:02 SMU 23836 pts/6 00:24:56 SMU
I want to write a separate C code where i want to create one linked list per one instance of
SMU to list all the PIDs of that process tree.
So I need know how can i find how many instances are running?, how to find PIDs with the same name?, which process is belongs to which process group and whether the process is Child or Parent?.
Are there any C APIs to do the job for me, and If I have to use
pstree, how can I use it to meet my requirement.