Hi,
Can't answer the POSIX version question, but I can for the SystemV - all the linux books I have only talk about SysV IPC (with the exception of saying that POSIX message queues are more flexible in Linux than SysV)
shmget - allocates
shmat - attaches. do this in the parent and there's no need to do it in the children
shmctl - amongst other things, call this to flag for deallocation.
shmdt - detach (NOT deallocate) happens automatically when process inheriting or attaching ends
Deallocation is explicitly required even when the allocating parent and all other attached processes die.
Deallocation happens at reboot(!), or when both of the following are true:
A process has used shmctl to flag the region for delete AND
All processes have detached, either by dying, or by calling shmdt.
I was tempted to flag for delete early, like unlinking a tmp file, but apparently this can have undesirable results platform by platform
Hope that's useful,
Andy T
Last edited by redhatstand; 12-31-2010 at 11:58 AM.
Reason: finger trouble
|