- 论坛徽章:
- 3
|
回复 8# goingstudy
是的.
这是我写的遍历所有进程的代码():
13 void read_child(struct task_struct* p)
14 {
15 struct task_struct *q = NULL;
16 if(!list_empty( &(p->children))){ /*p有子进程*/
17 list_for_each_entry(q, &(p->children), sibling ){
18
19 printk("<7> pid:%d, comm:%s\n",q->pid, q->comm);
20 read_child(q);
21 }
22 }
23 }
24
25 static int __init init_mm_init(void)
26 {
27 struct task_struct *p = &init_task;
28 struct task_struct *q = NULL;
29 printk("<7> pid:%d, comm:%s\n",p->pid, p->comm);
30
31 read_child(p);
return 0 ;
}
|
|