Content-type: text/html
mq_notify - Attaches a request for asynchronous signal notification to a message queue (P1003.1b)
#include <mqueue.h>
int mq_notify (
mqd_t mqdes,
const struct sigevent *notification);
Attaches a request for asynchronous signal notification to a message queue for the calling process. Following a call to this function, the specified signal is sent to the calling process when the queue transitions from empty to non-empty. Two or more processes cannot attach notification requests to the same queue at the same time.
If a process has attached a notification request and any process is blocked in the execution of the mq_receive function waiting to receive a message when a message arrives at the queue, then the appropriate mq_receive function is completed and the notification remains pending.
When the notification has been sent, the registration is canceled. In effect, it is a one-shot notification and must be re-registered if required.
Note that the POSIX IPC functions are not reentrant with respect to signals. For example, if your application were to use a signal to notify it that a queue has become non-empty and then attempt to call mq_receive from the signal handler, the signal handler must reside in a thread other than the tread that called mq_send. Otherwise, a deadlock on internal locks would occur.
On successful completion, the function returns the value 0; otherwise, the function returns the value -1 and sets errno to indicate the error.
The mq_notify function fails under the following conditions:
Functions: mq_open(3), mq_send(3) delim off