我想进入一个进程的子任务(进程)列表,这里是代码:
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);
}
当前的pid是正确的,但是孩子的pid不正确。 我做错了什么?
答案 0 :(得分:5)
child_task = list_entry(&children_list,struct task_struct,children);
注意,list_entry的最后一个参数应该是children
btw:如果您对list_entry不是很熟悉,那么下面的文章是一个很好的来源: http://isis.poly.edu/kulesh/stuff/src/klist/