The shm_open() function enables you to create shared memory and associate a file descriptor. Use the shm_unlink() function to remove (unlink a file descriptor from a shared memory) the name of the shared memory object.
Example:
#include <stdio.h> #include <sys/mman.h> #include <fcntl.h> #include <errno.h> int main(void) { int fd;// File Descriptor int ret; if((fd = shm_open("page", O_RDWR|O_CREAT, 0666)) < 0) { printf("Shared memory creation failed with errno %d\n", errno); } else { printf("Shared memory creation was successful\n"); } close(fd);//closing the file descriptor if((ret = shm_unlink("page")) < 0) { printf("Shared memory unlinking failed with errno %d\n", errno); } else { printf("Shared memory unlinking was successful\n"); } return ret; }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.