title: mq_notify not notifying about an event (Linux programming)
body: <p>I'm using <code>mq_notify</code> to be notified about events on a message queue, but my registered notifier function is not being called.  Did I miss something?</p>
  
  <p>I'm pasting my code snippet below:</p>
  
  <hr>
  
  <pre><code>static void sigNotifier(union sigval sv)
  {
     printf ("I'm called.\n");
  }    
  
  int main()
  {
     mqd_t queueID = 0;
     message_t msg;
     int retval;
     struct mq_attr attr;
     struct sigevent sev;
  
     attr.mq_msgsize = MSG_SIZE;
     attr.mq_maxmsg = 30;
  
     errno = 0;
  
     queueID = mq_open(MSG_QUEUE_NAME, O_RDONLY, 0666, &amp;attr);
  
     if (queueID == -1) {
        printf ("Message queue open failed: %d\n", errno);
     }
  
     sev.sigev_notify = SIGEV_THREAD;
     sev.sigev_notify_function = sigNotifier;
     sev.sigev_notify_attributes = NULL;
     sev.sigev_value.sival_ptr = &amp;queueID;
  
     retval = mq_notify(queueID, &amp;sev);
     if (retval &lt; 0) {
        printf ("Notification failed: %d\n", errno);
     }
  
     while (1);    
  }
  </code></pre>