Tag: 工作

如何在内核代码中获取子进程列表

我想到一个进程的子任务(进程)列表,这里是代码: 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不正确。 我究竟做错了什么?