I try to echo a simple message into mqueue, but the terminal always returns an error about echo command.
Example:
/dev/mqueue$ echo domen >> my_queue
bash: echo: write error: Invalid argument
Command ls -li
in folder /dev/mqueue returns:
total 0
29823 -rw-rw-r-- 1 domen domen 80 dec 24 14:18 my_queue
I create the mqueue in my C program the following way:
int fd_queue;
char queue_name[] = "/my_queue";
char message[4097];
struct mq_attr queue_parameters;
queue_parameters.mq_maxmsg = 5;
queue_parameters.mq_msgsize = 4096;
fd_queue = mq_open(queue_name,O_RDWR|O_CREAT|O_EXCL,0664, &queue_parameters);
What is the problem, that I can not write into queue using terminal commands?
The fundamental problem is that the shell doesn't open the message queue with mq_open()
and echo
doesn't use mq_send()
to write the message. Those are the tools that are needed. You'd need to write an mqecho
command to write to a message queue, and an mqread
command to read from a message queue.