I am trying to allow two different processes to communicate using the memory mapping of the same file. However, I am having some problems with this. I have a feeling that this is due to the way I use the open () call and pass my file descriptor to mmap.
Here is my code, do you see something wrong?
Object Code 1:
16 FILE* temp = fopen(theSharedFileName, "w"); 17 fseek(temp, fileSize-1, SEEK_SET); 18 fprintf(temp, "0");
I use the "w" file mode since Object 1 will ever be created once, and I want it to reset to have any previously existing data.
Object Code 2:
130 FILE* tempFile = fopen(sharedFileName, "a"); 131 int theFile = fileno(tempFile); ... 135 sharedArea = (MyStruct*)mmap(NULL, fileSize, 136 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_SHARED, theFile, 0);
samoz source share