Call shmdt("shared memory sharing") in the shared memory segment in each process that contains a link to it. Unix shared memory sections are counted by reference, so when the last process is separated from them, they can be destroyed using shmctl(id, IPC_RMID, NULL).
From outside your application, the only thing I can think of right now is to clear the shared memory segments:
for (int id=0; id < INT_MAX; id++)
shmctl(id, IPC_RMID, NULL);
but this is a terribly ineffective coolge. (I'm also not sure if it works, but not Linux, but Linux violates the Unix standard, while MacOS X is certified against it.)
source
share