PDA

View Full Version : Failure of creating shared memory in Fedora 8



jaganbabu
19th November 2009, 03:33 PM
Hi,

I am using Fedora 8 in my PC and i'm trying to create a shared memory (below is the sample program) i'm getting error while creating shared memory. Can anyone pl tell what is the possible cause for this.


#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <errno.h>
#define SHARED_LIST_MEMORY_KEY 0x3001
#define SHMFLG 0x1FF
int main()
{


int shared_memory_id;

if((shared_memory_id=shmget( SHARED_LIST_MEMORY_KEY,5, SHMFLG|IPC_CREAT )) == -1)
{
printf("\n Shared memory NOT created errno %d ", errno);
}
else
{
printf("\n Shared memory created %d ", errno);
}
}

OUTPUT: Shared memory NOT created errno 13



Thanks,
Jaganbabu

giulix
19th November 2009, 08:41 PM
ERRNO 13 is permission denied (EACCES). See http://www.opengroup.org/onlinepubs/009695399/functions/shmget.html

jaganbabu
20th November 2009, 07:49 AM
Thanks for the link.

EACCES: A shared memory identifier exists for key but operation permission as specified by the low-order nine bits of shmflg would not be granted; see XSI Interprocess Communication.

Even though i restarted my PC, the shared memory is not released. so i did an explict release of those shared memories, then it worked. Now i'm able to create the shared memory.


Thanks,
Jaganbabu