.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
-.\"
+.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
-.\" the use of the information contained herein.
-.\"
+.\" the use of the information contained herein.
+.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.fi
.SH DESCRIPTION
.BR mq_notify ()
-allows the calling process to register or unregister for delivery of
-an asynchronous notification when a new message arrives on
+allows the calling process to register or unregister for delivery of
+an asynchronous notification when a new message arrives on
the empty message queue referred to by the descriptor
.IR mqdes .
-The
+The
.I notification
-argument is a pointer to a
+argument is a pointer to a
.I sigevent
structure that is defined something like the following:
.in +0.25i
.fi
.in -0.25i
.PP
-If
+If
.I notification
-is a non-NULL pointer, then
+is a non-NULL pointer, then
.BR mq_notify ()
registers the calling process to receive message notification.
-The
-.I sigev_notify
+The
+.I sigev_notify
field of the
.I sigevent
to which
This field has one of the following values:
.TP
.B SIGEV_NONE
-A "null" notification: the calling process is registered as the target
+A "null" notification: the calling process is registered as the target
for notification, but when a message arrives, no notification is sent.
.\" When is SIGEV_NONE useful?
.TP
.B SIGEV_SIGNAL
Notify the process by sending the signal specified in
.IR sigev_signo .
-If the signal is caught with a signal handler that
+If the signal is caught with a signal handler that
was registered using the
.BR sigaction (2)
.B SA_SIGINFO
is set to
.BR SI_MESGQ ;
.I si_signo
-is set to the signal number;
+is set to the signal number;
.I si_value
is set to the value specified in
.IR notification->sigev_value ;
The function is invoked with
.IR notification->sigev_value
as its sole argument.
-If
+If
.IR notification->sigev_notify_attributes
is not NULL, then it should point to a
.I pthread_attr_t
Only one process can be registered to receive notification
from a message queue.
-If
+If
.I notification
is NULL, and the calling process is currently registered to receive
notifications for this message queue, then the registration is removed;
-another process can then register to receive a message notification
+another process can then register to receive a message notification
for this queue.
-Message notification only occurs when a new message arrives and
+Message notification only occurs when a new message arrives and
the queue was previously empty.
If the queue was not empty at the time
.BR mq_notify ()
-was called, then a notification will only occur after
+was called, then a notification will only occur after
the queue is emptied and a new message arrives.
If another process or thread is waiting to read a message
from an empty queue using
.BR mq_receive (),
-then any message notification registration is ignored:
+then any message notification registration is ignored:
the message is delivered to the process or thread calling
.BR mq_receive (),
and the message notification registration remains in effect.
-Notification occurs once: after a notification is delivered,
-the notification registration is removed,
+Notification occurs once: after a notification is delivered,
+the notification registration is removed,
and another process can register for message notification.
If the notified process wishes to receive the next notification,
-it can use
+it can use
.BR mq_notify ()
to request a further notification.
This should be done before emptying all unread messages from the queue.
-(Placing the queue in non-blocking mode is useful for emptying
+(Placing the queue in non-blocking mode is useful for emptying
the queue of messages without blocking once it is empty.)
.SH RETURN VALUE
On success
.BR mq_notify ()
returns 0; on error, \-1 is returned, with
-.I errno
+.I errno
set to indicate the error.
.SH ERRORS
.TP
.B EBADF
-The descriptor specified in
+The descriptor specified in
.I mqdes
is invalid.
.TP
.I notification->sigev_notify
is not one of the permitted values; or
.I notification->sigev_notify
-is
-.B SIGEV_SIGNAL
-and
+is
+.B SIGEV_SIGNAL
+and
.I notification->sigev_signo
is not a valid signal number.
.TP
The following program registers a notification request for the
message queue named in its command-line argument.
Notification is performed by creating a thread.
-The thread executes a function which reads one message from the
+The thread executes a function which reads one message from the
queue and then terminates the process.
.nf