I'm working on a project that involves writing a new system call for Linux 3.18.20. This system call is supposed to store various information about the currently running process in a newly defined struct.
One of the fields of the struct is the PID of the process's youngest child, and I've been searching for information about this in the struct task_struct, as defined here: http://lxr.free-electrons.com/source/include/linux/sched.h. I've been testing my new system call, and I can't seem to find the appropriate PID value from the struct list_head children.
My test function involves forking a child, storing the return value of fork, and comparing it to the value I get from doing various things in the parent's task_struct. I got the parent's task_struct, and I tried all of the following macros for struct list_head to get the correct PID. None of them have been correct.
printk("list_next_entry pid = %d\n", list_next_entry(task, children)->pid);
printk("list_prev_entry pid = %d\n", list_prev_entry(task, children)->pid);
printk("list_entry pid = %d\n", list_entry(&task->children, struct task_struct, children)->pid);
printk("list_first_entry pid = %d\n", list_first_entry(&task->children, struct task_struct, children)->pid);
printk("list_last_entry pid = %d\n", list_last_entry(&task->children, struct task_struct, children)->pid);
Is this even close to the correct way to try to find the youngest child of the parent process? How can I find a process's youngest child's PID from that process's task_struct?