Help! Shared memory is getting deleted after process is killed
- From: "Anuradha" <anuradhacb@xxxxxxxxxxxxxx>
- Date: 20 Jul 2006 01:42:23 -0700
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;
}
.
- Follow-Ups:
- Re: Help! Shared memory is getting deleted after process is killed
- From: "Nils O. Selåsdal"
- Re: Help! Shared memory is getting deleted after process is killed
- Prev by Date: ZModem communication within C Applications?
- Next by Date: Re: Help! Shared memory is getting deleted after process is killed
- Previous by thread: ZModem communication within C Applications?
- Next by thread: Re: Help! Shared memory is getting deleted after process is killed
- Index(es):
Relevant Pages
|