I have not been able to create and open a message queue in C.
I tried with various arguments to mq_open() function yet nothing has come out of it.
I have checked some similar issues, but have not been able to get a solution.
I am not sure what I am doing wrong.
I am getting a mq_open: Invalid argument error.
// Create the message queue
mqd_t mq;
// Open the message queue
mq = mq_open(argv[1], O_RDONLY | O_CREAT, 0666, NULL);
if (mq == (mqd_t)-1) {
perror("mq_open");
exit(EXIT_FAILURE);
}
I am arbitrarily giving it the name 'a'.
That is an invalid name for a message queue. Such names must begin with a leading "/". This spelled out in the man page for mq_overview, which is referenced in the man page for mq_open: