Hi all,
I am using mmap to obtain some space(mapped anonymously) and am giving the address of the assigned space to a struct pointer. Then I want to access a member of the struct that the pointer points to. The code is:
//----begin
struct foo{
int test;
}foo;
struct foo one,*one_ptr;
one_ptr=mmap(NU LL,sizeof(one), PROT_READ|PROT_ WRITE,MAP_ANON,-1,0);
*one_ptr = one;
one_ptr->test =0;
//---end
but I get a SIGSEGV at "*one_ptr = one". If I remove the line, then I get a SIGSEGV at the following line "one_ptr->test =0"
The reason for using mmap is I have to obtain some memory that is to be shared by a bunch of "processes" . The processes should use the same memory and struct is being used to utilize the memory.
Thanks for your help
I am using mmap to obtain some space(mapped anonymously) and am giving the address of the assigned space to a struct pointer. Then I want to access a member of the struct that the pointer points to. The code is:
//----begin
struct foo{
int test;
}foo;
struct foo one,*one_ptr;
one_ptr=mmap(NU LL,sizeof(one), PROT_READ|PROT_ WRITE,MAP_ANON,-1,0);
*one_ptr = one;
one_ptr->test =0;
//---end
but I get a SIGSEGV at "*one_ptr = one". If I remove the line, then I get a SIGSEGV at the following line "one_ptr->test =0"
The reason for using mmap is I have to obtain some memory that is to be shared by a bunch of "processes" . The processes should use the same memory and struct is being used to utilize the memory.
Thanks for your help
Comment