I am trying to traverse a task_struct's children in the linux kernel and get information from the children. I'm having problems with all the information, so let's just keep it at the getting the pid for simplicity.
This is the relavant part of my code.
struct list_head * p;
struct task_struct ts, *tsk;
pid_t tmp_pid;
INIT_LIST_HEAD(&ts.children);
current = tsk;
list_for_each(p, &(tsk->children)){
ts = *list_entry(p, struct task_struct, children);
tmp_pid = ts.pid;
printk("the pid is %d\n", tmp_pid);
}
I think the problem is with list_entry but I don't know how to fix it, all the examples I can find seem to be calling it the same way.
This should print out all the child PIDs, instead I always get the same number -17.... it's on the order of 10^9 or 10^11.
can anyone help me out here? compiling takes about 30 minutes, so trying a log of different things isn't really an option.