shmat:invalid arguments

bipinc5

New Member
Credits
14
Hello,
i am trying to write a code that implements shared memory mechanism in IPC. whenever i execute shmat() i get "invalid argument" error.Can someone guide me what is wrong with my code.
(all necessary header files are included).


int main()
{
char *ptr;
int shmid;
key_t key=4488;
if(shmid=shmget(key,sizeof(int),IPC_CREATE|0666)<0)
{
perror("shmget");
}
if(ptr=shmat(shmid,NULL,0666)==-1)
{
perror("shmat");
}

}
 




Members online


Top