-
-
Save drmalex07/5b72ecb243ea1f5b4fec37a6073d9d23 to your computer and use it in GitHub Desktop.
@pharapeti
it is the ownership mode, just like in the open
system call
Thank you for this example. It was really helpful.
However, I have a question. Any particular reason for not using shm_unlink
or munmap
? Is it not necessary?
@DharminB
shm_unlink
would delete the shared memory region from the OS (it appears under /dev/shm); in many cases we want it to remain for other processes to read/write to it.
munmap
would destroy (invalidate) the memory mapping for the pointer pointing to the shm region. This affects only the current process and it automatically happens when the process terminates.
shm_unlink
would delete the file under /dev/shm/xxxxx even there are other processes using it ?
@samuel100u
no, it uses a reference-count approach: the OS will delete the region only when all processes have been unlinked. See also the man page
What does
0644
mean inshm_open(name, oflags, 0644 );
?