On Wed, 2006-05-31 at 17:25 +0200, tyler@xxxxxxxx wrote: > On Tue, May 30, 2006 at 10:04:47PM -0700, Nish Aravamudan wrote: > > On 31 May 2006 04:54:23 -0000, rohit hooda <rohit13hooda@xxxxxxxxxxxxxx> wrote: > > > > > > On Wed, 31 May 2006 Taha Hafeez Siddiqi wrote : > > > > > > >On Tue, 2006-05-30 at 17:20 +0530, Gopala Krishna wrote: > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > > >Hi all, > > > > > > > >I think there is another way.* > > > > > > > >You can get hold of your current, use its list to get hold of the > > > >process structure and the up you go using the process->parent.... > > > > > > > >It may not be the correct way, but I suppose surely it is one way of > > > >doing it*. > > > > > > > > > Well in kernel mode, if you have the PID of a process, from that you can have > > >its task_struct and then you can iterate down to get the lists of its children and > > >grand children and so on ... but over here we have to do things in user space n > > >not in kernel space > > > > Then please take it off this list (KERNELnewbies). > > > > Thanks, > > Nish > > > > Well Taha wants to implement it in user space. But in someway, the > process and procfs subsystems are close to the kernel. Don't say him to go away !:) > Hi all, Firstly, I am not the one asking the question :) I gave the answer using a module, so if one needs a solution in user space, he can use the module as a char device driver or implement it using procfs and if one needs a solution in kernel then he is already at the right place to use my idea .... On the matter whether this is our (KernelNewbies) issue, I agree with Nish that if whole solution has to be implemented in user space then the question doesn't belong here.... :) regards Taha -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/