Things I learned calling shm_open() on a Mac
- The shared memory object name passed to
shm_open()
must contain only one slash (the leading slash). - The object name passed to
shm_open()
must be at most 31 characters long, including the leading slash and leaving out the trailing null. If it's longer, you get an error. - You can't
write()
to the file descriptor returned byshm_open()
. Attempting to do so results in aDevice not configured
error. - If you
ftruncate()
the shared memory object more than once, that's an error — even if you doftruncate()
to the result of differentshm_open()
calls with the same object name in different runs of the same program.
Unrelated to shm_open()
, but as part of the same project, I learned that the correct way to throw an exception in C++ is throw exception(...)
, not throw new exception(...)
. I am too used to seeing C# and Java code snippets where the latter is correct.