内核:如何遍历当前进程的孩子? [英] Kernel: how to iterate the children of the current process?

查看:117
本文介绍了内核:如何遍历当前进程的孩子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux内核开发,第三版,这code被赋予遍历当前进程的孩子。

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?

推荐答案

兄弟是名称 LIST_HEAD 结构结构的task_struct 对应于父母的孩子名单。

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

也就是说,在这个循环列表总是指向一个兄弟的成员结构的task_struct 孩子父成员。

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

这篇关于内核:如何遍历当前进程的孩子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆