c - mq_notify not notifying about an event (Linux programming) -
i'm using mq_notify
notified events on message queue, registered notifier function not being called. did miss something?
i'm pasting code snippet below:
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, &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 = &queueid; retval = mq_notify(queueid, &sev); if (retval < 0) { printf ("notification failed: %d\n", errno); } while (1); }
because code copies man page ask:
- are sure sending message queue correctly?
- try first read using blocking read , see if something.
under linux can use select/poll/epoll wait notifications queue mqd_t ordinary file descriptor.
Comments
Post a Comment