Linux-2.6.35.13 kernel/sched.c 有一个函数 find_process_by_pid()。我尝试使用以下代码:
int main()
{
struct task_struct *p;
pid_t pid;
pid=2130;
p = find_process_by_pid(pid);
printf("task_struct.state: %s\n", p->state);
return 0;
}
$ gcc getProcbyId.c -o getProcbyId
得到以下警告和错误:
getProcbyId.c: In function 'main':
getProcbyId.c:19:4: warning: assignment makes pointer from integer without a cast
getProcbyId.c:21:37: error: dereferencing pointer to incomplete type
请给出如何解决这个问题的建议。