In Linux Kernel Development, 3rd ed, this code was given for traversing the children of the current process.
list_for_each(list, ¤t->children) {
task = list_entry(list, struct task_struct, sibling);
/* task now points to one of current’s children */
}
The “sibling” in this idiom looks out of place. What is its purpose?
siblingis the name of thelist_headstructure instruct task_structthat corresponds to the parent’s children list.That is, in this loop
listalways points to asiblingmember of astruct task_struct, or thechildrenmember of the parent.