I want to get to the children task (process) list of a process, here is the code:
void myFunc()
{
struct task_struct* current_task;
struct task_struct* child_task;
struct list_head children_list;
current_task = current;
children_list = current_task->children;
child_task = list_entry(&children_list,struct task_struct,tasks);
printk("KERN_INFO I am parent: %d, my child is: %d \n",
current_task->pid,child_task->pid);
}
The current pid is right, but the child pid is not correct. What am I doing wrong?
child_task = list_entry(&children_list,struct task_struct,children);
Note, the last parameter to the list_entry should be children
btw: if you are not very familiar with list_entry, following article is a good source: http://isis.poly.edu/kulesh/stuff/src/klist/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With