Reputation: 785
i am trying to know the size of task_struct. thus i have downloaded the linux source code from the website and i have generated the head files via typing the command make headers_install
into terminal in the source code file root directory.
#include<stdio.h>
#include<linux/sched.h>
int main()
{
printf("%d\n",sizeof(struct task_struct)).
return 0;
}
typing the command to the termial to compile and source code gcc -g -I *path/to/linux*-source/usr/include test.c -o test
. However the terminal shows struct task_struct does not define stuff.
Could any guys to help me to figure it out? Really appreciated.
Upvotes: 1
Views: 157
Reputation: 3768
This struct is for kernel internal use only. It's definition is pretty long and largely varies depending on kernel configuration. So, the struct size also varies depending on kernel configuration, and you can't get it from user-space.
Unless, you extract kernel config, which is bad idea, as for me. The better one is to write a kernel module.
Upvotes: 3