How to find the child processes?

Dave Hylands dhylands at gmail.com
Sat Feb 11 00:12:02 EST 2012


Hi Suren,

On Fri, Feb 10, 2012 at 7:45 PM, Surenkumar Nihalani <suren at gatech.edu> wrote:
> Hi guys,
>
> I need help, again. I am writing a kernel module. I have the pid and tid
> from the current structure. How do I figure our the number of threads in the
> given process id?
> If possible, how do I get the individual tids within the pid?

So I took a look at how /proc/TTT/task was implemented, and basically
it uses next_thread from sched.h, which follows the thread_group
structure stored inside task_struct.

You need to acquire the appropriate locks and do checks to make sure
that the thread hasn't died on you, but that's the jist of it.

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com



More information about the Kernelnewbies mailing list