5
我想要去的過程中孩子們的任務(進程)列表,這裏是代碼:我怎樣才能在內核代碼孩子進程列表
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不正確。 我在做什麼錯?
我所不知道的關於linux-kernel,但我覺得它應該是'struct list_head * children_list'和後來'children_list =&current_task-> children'。 – 2011-04-20 10:09:47
謝謝,但'current_task-> children'返回'list_head'而不是'list_head *' – Noga 2011-04-21 05:02:03
我知道它已經過了5年,但@king_nak說的是你**不應該複製struct,而是使用指針指着它。所以你把'&'放在current_task-> children之前。 – 2017-03-15 16:40:26