在Linux Kernel Development,第3版中,这段代码用于遍历当前进程的子代.
list_for_each(list, ¤t->children) {
task = list_entry(list, struct task_struct, sibling);
/* task now points to one of current’s children */
}
Run Code Online (Sandbox Code Playgroud)
这个成语中的"兄弟姐妹"看起来不合时宜.它的目的是什么?
sibling是与父项子项列表对应的list_head结构名称struct task_struct.
也就是说,在此循环中list始终指向a的sibling成员struct task_struct或children父成员.