How do I get a list of all pids on 2.6? (what's wrong with this code)

From: Jed Brazos
Date: Sat Jan 29 2005 - 14:25:46 EST


Hi,

I'm trying to list all of the tasks and their
children. (Im using a 2.6.5-7 kernel)

The code below does not list all of the pids as
compared to the /proc entries.

Why does the following code not list all of the
active pids in the system?

please cc this id.

-----------------------




void list_pids(void)
{
struct task_struct *tp;
struct list_head *_p;
struct list_head *_n;
struct task_struct *p;


read_lock(&tasklist_lock);
for (tp = &init_task; (tp = next_task(tp)) !=
&init_task; ) {
printk("[parent] pid =%d \n" ,tp->pid );
list_for_each_safe(_p,_n, &tp->children ){
p = list_entry(_p,struct
task_struct,sibling);
printk(" [child] pid =%d \n", p->pid
);

}
}
read_unlock(&tasklist_lock);
return ;
}






__________________________________
Do you Yahoo!?
All your favorites on one personal page ? Try My Yahoo!
http://my.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/