Help! Shared memory is getting deleted after process is killed



Hi!

I have a requirement wherein the shared memory *should not be*
destroyed after the process is killed. Though I am not doing any clean
up, the sharedmemory is getting cleared. Can anyone of you let me know
why this is happening.

(Note that the created shred memory is not meant for either read/write.
I need to know if the process has crashed or the system rebooted &
hence this little code)

Code:
{
static key_t key;
static struct shmid_ds shmbuff;
int shmId;
void * shmBase = NULL;

memset(&shmbuff, 0 , sizeof(struct shmid_ds) ) ;
if((key = ftok("/tmp", 87654321) == (key_t)-1 )
{
return 0;
}
if( (shmId = shmget(key, 1, IPC_CREAT | IPC_EXCL | 0600)) == -1 )
{
if( errno == EEXIST )
{

return 1;
}
}
if(( (shmBase) = shmat(shmId, NULL, 0)) == (void *)-1 )
{
printf("Unable to attach to shared memory \n");
}
return 0;
}

.



Relevant Pages