mq_notify()

Просить получать уведомления, когда в очереди есть сообщение

Прототип:

#include <mqueue.h>
int mq_notify( mqd_t mqdes,
const struct sigevent *notification );

Аргументы:

mqdes
The message-queue descriptor, returned by mq_open(), of the message queue that you want to get notification for.
notification
NULL, or a pointer to a struct sigevent that describes how you want to be notified.

Библиотека:

Описание:

If notification isn't NULL, the mq_notify() function asks the server to notify the calling process when the queue makes the transition from empty to nonempty. The means by which the server is to notify the process is passed in the struct sigevent pointed to by notification. Once the message queue server has notified the process of the transition, the notification is removed.


Note: Neutrino supports two implementations of message queues: a traditional implementation, and an alternate one that uses asynchronous messages. For more information, see the entries for mq and mqueue.

We recommend that you use the following event types in this case:

SIGEV_SIGNAL
SIGEV_SIGNAL_CODE
SIGEV_SIGNAL_THREAD
SIGEV_PULSE

Under normal operation, only one process may register for notification at a time. If a process attempts to attach a notification, and another process is already attached, an error is returned and errno is set to EBUSY.

If a process has registered for notification, and another process is blocked on mq_receive(), then the mq_receive() call is satisfied by any arriving message. The resulting behavior is as if the message queue remained empty.

If notification is NULL and the current process is currently registered for notification, then the existing registration is removed.

Возвращаемое значение:

-1
Возникла ошибка. Код ошибки записан в errno.
≠-1
Успешное завершение.

Коды ошибок:

EBADF
Invalid message queue mqdes.
EBUSY
A process has already registered for notification for the given queue.

Классификация:

POSIX 1003.1 MSG

Точка остановки потока
Нет
Обработчик прерываний
Нет
Обработчик сигналов
Нет
В потоке
Да

Тематические ссылки:

mq_open(), mq_receive(), mq_send(), struct sigevent

mq, mqueue в Справочнике по Утилитам




Предыдущий раздел: Описание API системной библиотеки