This is the struct:
typedef struct Queue {
int data[MAX_SIZE];
long front;
long back;
int size;
int mysize;
} Queue;
and this is the code:
if((queueShmid = shmget(IPC_PRIVATE, sizeof(Queue), IPC_CREAT | IPC_EXCL ))==-1) {
printf("Shared memory segment exists - opening as client\n");
/* Segment probably already exists - try as a client*/
if((queueShmid = shmget(IPC_PRIVATE, 2*sizeof(Queue), 0)) == -1)
{ perror(" bad shmget"); exit(1);}
}
Queue *queue = (Queue*) shmat(queueShmid, NULL, 0);
if(queue=NULL) {
perror("bad shmat"); exit(1);
}
if ((int) queue < 0) {
printf("shmat() failed %d \n",(int)queue); exit(1);
}
printf ("shared memory attached at address %p\n", queue);
its return: shared memory attached at address (nil),
any other shared memory work well, any idea?