I've started playing with mmap. I'm trying to create an example workspace that will be then extended to the real case.
This is what I want to achieve:
PROCESS 1:
- mmap a file (actually a device, but it's okay to generate an example with a text file)
PROCESS 2: (not foked from process 1; just an independent process)
- read the memory mapped by process 1
- change some bits
- write it to a new file
I've read several examples and documentations, but I still didn't find how to achieve this. What I'm missing is:
- how can process 2 access the memory mapped by process 1, without knowing anything about the opened file?
- how can I put the mmap content in a new file? I suppose I have to ftruncate a new file, mmap this file and memcpy the content of process 1 memory map to process 2 memory map (then msync)
Side info, I have a message queue opened between the two processes, so they can share some messages if needed (ex. the memory address/size, ...).
Any hints?
Thanks in advance!
MIX