shmat:invalid arguments

bipinc5

New Member
Joined
Jun 25, 2020
Messages
1
Reaction score
0
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