base: delete shared memory segments when processes exit
@@ -182,6 +182,12 @@ void *mem_map_shm(mem_key_t key, void *base, size_t len, size_t pgsize,
if (addr == MAP_FAILED)
return MAP_FAILED;
+ /* mark the shm segment for destruction after the process dies */
+ if (exclusive) {
+ if (shmctl(shmid, IPC_RMID, NULL) == 1)
+ return MAP_FAILED;
+ }
+
touch_mapping(addr, len, pgsize);
return addr;
}
