I got the following piece of C code which executes successfully:
...
fd = shm_open(memory_package_name, O_CREAT | O_RDWR | O_EXCL , S_IRUSR | S_IWUSR);
if (fd == -1) { //will fail if file already exists because of flag O_EXCL
printf("\n shm_open() failed with error [%s]\n",strerror(errno));
exit(EXIT_FAILURE);
} else {
printf("shm_open success\n");
}
...
Using ls -l /dev/shm
I see the file with name memory_package_name
correctly created, but when I use ipcs
it doesn't show any shared memory segment(s):
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
Why?