As I am writing a school project in c and I am having trouble with using shared memory. For some reason my solution worked once and now it doesn't (very unscientific, I know).
I create a shared variable:
int *sharedVar = mmap(NULL, sizeof(int)*7, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
And when I try to use it like this:
sharedVar[0]=1;
or this:
sharedVar[4]=0;
I get a Segmentation Violation (SIGSEGV) error message. I will be happy for any of your suggestions.
EDIT: strerror says:
Bad file descriptor
What does that mean?
SOLUTION: I haven't cleaned my memory. I feel stupid.