Reputation: 19050
I am using shmget
, shmat
and shmctl
to respectively get and create a shared memory segment, attach it in processes address space and remove it.
I am wondering if processes can still use the shared memory segment even if it has been detached and asked for removal using
shmctl(id, IPC_RMID, ...)
in one process.
I am not able to get the information from the man page:
IPC_RMID
Mark the segment to be destroyed. The segment will only actually be destroyed after the last process detaches it (i.e., when theshm_nattch
member of the associated structureshmid_ds
is zero). The caller must be the owner or creator, or be privileged. If a segment has been marked for destruction, then the (nonstandard)SHM_DEST
flag of theshm_perm.mode
field in the associated data structure retrieved byIPC_STAT
will be set.
Upvotes: 4
Views: 1053
Reputation: 316
On Linux, it is possible to attach a shared memory segment even if it is already marked to be deleted. However, POSIX.1-2001 does not specify this behavior and many other implementations do not support it.
Upvotes: 1