I have a process that needs two active connections to the same zone of shared memory simultaneously.
The firs conection works ok, but when i do the second call to shmat it give me error 22 (EINVAL). Only works ok the second call to shmat if i disconnect the first connection (shmdt)
Steps: I�m going to shared a integer.
1�.- Create shared memory OK:
iIdentificador = shmget(5000,sizeof(int),IPC_CREAT | 0777); //In the original source the key is not hardcode...
2�.-Connection 1 and view the integer shared. Works OK:
piIntegerShared_1=(int *)shmat(iIdentificador,NULL,0))
printf("\n\t =>Dato compartido [%ld]\n",*piIntegerShared_1);
3�.-Connection 2: ERROR !!!:
if((piIntegerShared_2=(int *)shmat(iIdentificador,NULL,0))==(void*)-1)
printf("\n\n\t ERROR shmat memoria2 [%d] [%s]",errno,strerror(errno));
Output: ERROR shmat memoria2 [22] [Invalid argument]
The connection 2 only works ok, if i before delete the connection 1 with:
shmdt(piIntegerShared_1);
Which is the problem in the step 3?
In Sun,AIX and Digital, i don�t have this problem all connection works ok. Only in HP-UX (Itanium - ia64) 11i Version 2: August 2003
Thanks,
David