> Hi all, > I'm trying to develop a C program that access to > process descriptor information but I have had some > problem with libraries. > In particular, I've developed a program like this: > > #include <linux/sched.h> > > int main(void){ > pid_t pid; > .... > task_struct process = find_task_by_pid(pid); > ... > } > > but the compiler can't find get_task_by_pid function, > while this is a function declared in > include/linux/sched.h. > What's wrong? The problem is that the function get_task_by_pid() lives in the kernel, and you cannot call arbitrary functions in the kernel (think of what that would mean to security and isolation). The functions you can access from user space are system calls. > Are there other methods to access process descriptor > pointer? If you need more than what is already available from the task_struct you would preferably add another system call to your linux (there are other ways too). Maybe something like: sys_get_task_struct(pid_t pid, struct task_struct __user *to) { task_struct *task = find_task_by_pid(pid); copy_to_user(to, task, sizeof(struct task_struct)); } Alex -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/