EDIT: I'm working on kubuntu 16.04LTS, and I'm using the kernel "linux-3.16.43.tar.xz" from The Linux Kernel Archives
Hi, I am making a system call that loops through every process with a certain status (passed to the syscall as a parameter) and show their Name, PID, UID and the name of their children. This is what I have so far:

Code:
asmlinkage int sys_procinfo(int state){
    struct task_struct *task;
    struct task_struct *child_ptr;
    struct list_head *list;


    for_each_process(task) {
        if(task->state == state){
            /* print info about the parent */
            printk(KERN_INFO "nombre:%s[pid:%d]estado:%ld[uid:%d]\n", task->comm, task->pid, task->state, task->uid);


            list_for_each(list, &task->children) {
                child_ptr = list_entry(list, struct task_struct, sibling);
                /* child_ptr now points to one of current's children */
                printk(KERN_INFO "Hijo %s\n", child_ptr->comm);
            }
        }
    }
    return 0;
}
This prints all of the system's processes and their children, completely ignoring the condition if(task->state == state), which is very weird to me. I need to print only the info of the processes that are in the state 'state' (e.g. TASK_RUNNING = 0, EXIT_ZOMBIE = 32, TASK_WAKING = 256, TASK_INTERRUPTIBLE = 1, etc).

Oh, and I also would like the syscall to return its syscall number, but I defined it for two systems: 32 and 64bits, and their numbers in the syscall_32.tbl and syscall_64.tbl tables are different, so I think I can't hardcode the syscall number. Is there any macro I can use to return that value?

Thanks.