Skip to content
Advertisement

Not able to open a message queue in read mode (mq_open())

I have a program which creates a message queue and send a message (with mq_send()) to this queue. then I try to open the same message queue to read the message from another process. But mq_open() returns -1.

open_and_write_MQ.c

JavaScript

This creates the MQ. Below program tries to read the same MQ. open_and_read_MQ.c

JavaScript

Compilation steps:

JavaScript

execution steps:

JavaScript

then run below program in some other terminal.

JavaScript

How can I set the permissions of process so that it can read the messages from message queue?

Advertisement

Answer

The problem is the line

JavaScript

7777 is not a number specified in octal. Use e.g. 0777 instead (or the S_I* constants described in open(2)). Those permissions might be overly broad though.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement