Re: How to get the pid of all children, grand children..../... of a process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Fortunately, here comes the proc filesystem !
So, you have the pid of the father process : look at the file
/proc/'ppid'/status there should be a fild ppid : you have the pid of
your grand parent.
You can do a recursive function to find all the ancestors of your
process.
This solution is quite annoying since you have to handle files, but it
works.

If this solution is not acceptable for you, you can look at the pstree
source code.

I don't know if you wanted to do that in your own programm or just
wanted some soft to give you the entire tree (like pstree). Anyway... :
 
 
In My case, I knew only pid of the first process. I want the top down approach rather than the bottom up (i.e if I know child, I know parent. but, my requirement is to find out child and it's grand children, If I know the parent pid). Currently I am going through pstree code.
 
Thanks and regards,
Gopal.

 

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux