Using shared memory and how to correctly unallocate a space with IPC_RMID

让人想犯罪 __ 提交于 2019-12-02 10:20:23

You don't say which operating system you are running on. If you're on Linux, OpenBSD 5.1 or later or other operating systems configured a particular way you may well be able to attach after having done IPC_RMID so long as something is still attached to it but bear in mind this behaviour is not portable (here's an older examination of IPC_RMID behaviour on different OSes). Without this behaviour it's going to be difficult to avoid stale segments being left behind if your program crashes (aka "doesn't exit graciously") when it's the last thing attached to the segment.

I should also note that your question sounds similar to the problem discussed over in Options for robust process cleanup over on the UNIX Socket FAQ forum where suggestions included: use Linux's IPC_RMID behaviour, have a monitoring parent process check for process death and do cleanup.

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