title: POSIX Message queues, errno 90, message too long
body: <p>I am currently doing a minimal IPC using POSIX Message Queues. I have one pipe that only will pass <code>uint8_t</code>'s as commands and another pipe that will pass strings with a length up to 128 characters. The command pipe is working fine. But the stringpipe will always give me errno number 90, which means <code>message too long</code>. I have written a minimal example demonstrating the issue (please note: i kept it minimal, so there is no errorhandling whatsoever besides the error upon receiving).</p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;mqueue.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;time.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  
  int msg_size = 128;
  
  int send()
  {
      struct mq_attr attr = {0, 10, msg_size + 1, 0};
      mqd_t mq = mq_open("/test", O_RDWR | O_CREAT, 00644, &amp;attr);
      char msg[msg_size] = {0};
      strncpy(msg, "this_is_a_test", msg_size);
      mq_send(mq, msg, msg_size, 0);
  }
  
  int recv()
  {
      struct mq_attr attr = {0, 10, msg_size + 1, 0};
      mqd_t mq = mq_open("/test", O_RDWR | O_CREAT, 00644, &amp;attr);
      char msg[msg_size] = {0};
      int res = mq_receive(mq, msg, msg_size, NULL);
      if (res == -1)
      {
          printf("Errno: %d\n", errno);
      }
      else
      {
          printf("Message: %s\n", msg); 
      }
  }
  
  int main()
  {
      send();
      recv();
      return 0;
  }
  </code></pre>
  
  <p>Compile with:</p>
  
  <pre><code>g++ -o mq mq.c -lrt
  </code></pre>