Skip to contentSkip to conversation

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

DISCUSSION Jed Brazos 1 participant 1 message Jan 29, 2005

lore
Share & tools
lore

Jed Brazos

author
#0 lore raw

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