I have two questions:
while using shm_open, how to know if I have opened an already existing shared memory, I am using O_CREATE | O_RDWR.
I am using shm_open to create/open a shared memory object with some name and mmap for mapping it into process' virtual address space. If the process crashes and fails to clean up shared memory it stays until system shutdown. Though it this contradictory with what has been mentioned on wiki, which says, "The shared memory created by shm_open is persistent. It stays in the system until explicitly removed by a process. This has a drawback that if the process crashes and fails to clean up shared memory it will stay until system shutdown. To avoid this issue mmap can be used to create a shared memory". I am talking about the file with name mentioned in shm_open, which gets created in /dev/shm, it remains if process gets crashed without cleaning up the shared memory (unmap and shm_unlink). I am expecting, if there are no other references to shared memory by any process, and the crashed process was the only one referring, that shared memory object and file should get cleaned up.