I'm using boost::interprocess::managed_mapped_file
to do IPC under linux. In short one process can write objects into files (method construct
) for another process to read (method find
). However what if the process crashes while writing? Will boost handle this automatically or I have to add a mechanism to detect such failure?
Asked
Active
Viewed 404 times
0

old_bear
- 279
- 1
- 5
- 14
-
1What if your power source goes down while writing? Neither you nor boost can reliably detect that from the writer's side. – Frédéric Hamidi Dec 30 '13 at 10:28
-
So I have to add something like checksum to validate the file? Or use the way(log file) database does? – old_bear Dec 30 '13 at 10:34
-
The reader side will notice something is wrong because the IPC channel will close unexpectedly. There are many ways to recover, including dropping the partial object and waiting for the writer to recover and send it again. – Frédéric Hamidi Dec 30 '13 at 10:36
-
Sorry, another question is that according to boost manual the writing method will automatically lock itself. So what happens to this lock if writer cashes? Will it cause deadlock on the reader side? It seems there is nothing about process-crashing on boost page – old_bear Dec 30 '13 at 10:42
1 Answers
0
If process crashes result is not defined - nothing can know how much I/O it could have done. But I would think that OS is probably doing I/O in some units, probably at least one block (512 bytes) or page (4KB).

mvp
- 111,019
- 13
- 122
- 148