Here is the code:
mode_t mode = S_IRUSR | S_IWUSR |
S_IRGRP | S_IWGRP |
S_IROTH | S_IWOTH;
struct mq_attr attributes;
attributes.mq_maxmsg = 100;
attributes.mq_msgsize = MSG_MAX_SIZE;
mqid = mq_open(QUEUE_NAME, O_RDONLY | O_CREAT, mode, attributes);
if ((mqd_t) -1 == mqid)
Obviously, MSG_MAX_SIZE and QUEUE_NAME are defined elsewhere.
After running this function for the first time, the QUEUE_NAME was created, but the permissions on the queue were:
Since I specified that every user should have "rw" access, but it didn't happen, I had to use chmod so other users could send messages to this queue.
This behavior is consistent with the default umask(2) setting of 022. What happens if you change that?
You're right. My bad. I should have thought of that.