multiple user of msgget(): Permission denied

I used ipc message to control the threads and process, and I want to use some threads to read the queue and others to write.

But I have got Permission Denied error when the msgget on the same KEY is invoked a second time.

In details:
Code:
   if(msgget(6789, IPC_CREAT|0777)==-1) perror();
          and i would get "Permission denied".
   if(msgget(6789, IPC_CREAT|IPC_EXCL|0777)==-1) perror();
          and i would get "File exists"

I guess that maybe ipc message can not be invoked two times, it's really stange!
 
The msgget(2) function creates a message queue if it doesn't exist. You're trying to create the same queue twice.
 
Back
Top