内核:如何迭代当前进程的子进程?

编程入门 行业动态 更新时间:2024-10-25 21:19:59
本文介绍了内核:如何迭代当前进程的子进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在 Linux Kernel Development, 3rd ed 中,此代码用于遍历当前进程的子进程.

In Linux Kernel Development, 3rd ed, this code was given for traversing the children of the current process.

list_for_each(list, &current->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?

推荐答案

sibling 是 struct task_struct 中的 list_head 结构的名称对应于父级的子级列表.

sibling is the name of the list_head structure in struct task_struct that corresponds to the parent's children list.

也就是说,在这个循环中,list 总是指向 struct task_struct 的 sibling 成员,或者 children代码>父级成员.

That is, in this loop list always points to a sibling member of a struct task_struct, or the children member of the parent.

更多推荐

内核:如何迭代当前进程的子进程?

本文发布于:2023-11-17 11:44:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609902.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进程   内核   迭代

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!