Do I need to use shm_unlink on a shared memory object?

痞子三分冷 提交于 2019-12-03 13:48:01
perh

The only leak is that the file will stay even after the last process that opened it exists.

But since that was the intent in this case it is not really a leak as such.

The files in /dev/shm behave just like regular files (because they are).

This means that the name can be removed (using unlink or shm_unlink) but the file data will remain until the name is gone and the last process using it stops doing so (having the file open or it's content mmap:ed counts as using it).

But there is only the one file, no matter how many times you open and/or mmap it.

And when a process exits all open file descriptors are closed, and all memory mappings are removed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!