That will work, except process B needs to open a handle to the memory mapped file before process A closes its handle. The reason is that the memory mapped file is destroyed when the last handle is closed.
(I assume we're talking Windows here.)
Edit: I got interested in this and did a bit more reading…
Probably the most correct and robust way to do this would be for process B to inherit a handle to to the memory mapping. Some links:
- Handle Inheritance in Windows
- Programmatically controlling which handles are inherited by new processes in Win32
- How do I pass a lot of data to a process when it starts up?
I think this last link provides you with a model answer by one of the most knowledgeable Windows programmers in the world. Do read the comments below the article as well.