]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - lib/libc/sys/mq_notify.2
MFC r320737, r320914
[FreeBSD/stable/10.git] / lib / libc / sys / mq_notify.2
1 .\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice(s), this list of conditions and the following disclaimer as
9 .\"    the first lines of this file unmodified other than the possible
10 .\"    addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice(s), this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .\" Portions of this text are reprinted and reproduced in electronic form
29 .\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
30 .\" Portable Operating System Interface (POSIX), The Open Group Base
31 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
32 .\" Electrical and Electronics Engineers, Inc and The Open Group.  In the
33 .\" event of any discrepancy between this version and the original IEEE and
34 .\" The Open Group Standard, the original IEEE and The Open Group Standard is
35 .\" the referee document.  The original Standard can be obtained online at
36 .\"     http://www.opengroup.org/unix/online.html.
37 .\"
38 .\" $FreeBSD$
39 .\"
40 .Dd July 15, 2016
41 .Dt MQ_NOTIFY 2
42 .Os
43 .Sh NAME
44 .Nm mq_notify
45 .Nd "notify process that a message is available (REALTIME)"
46 .Sh LIBRARY
47 .Lb librt
48 .Sh SYNOPSIS
49 .In mqueue.h
50 .Ft int
51 .Fn mq_notify "mqd_t mqdes" "const struct sigevent *notification"
52 .Sh DESCRIPTION
53 If the argument notification is not
54 .Dv NULL ,
55 this system call will register the calling process to be notified of message
56 arrival at an empty message queue associated with the specified message
57 queue descriptor,
58 .Fa mqdes .
59 The notification specified by the
60 .Fa notification
61 argument will be sent to
62 the process when the message queue transitions from empty to non-empty.
63 At any time, only one process may be registered for notification by a
64 message queue.
65 If the calling process or any other process has already
66 registered for notification of message arrival at the specified message
67 queue, subsequent attempts to register for that message queue will fail.
68 .Pp
69 The
70 .Fa notification
71 argument points to a
72 .Vt sigevent
73 structure that defines how the calling process will be notified.
74 If
75 .Fa notification->sigev_notify
76 is
77 .Dv SIGEV_NONE ,
78 then no signal will be posted, but the error status and the return status
79 for the operation will be set appropriately.
80 For
81 .Dv SIGEV_SIGNO
82 and
83 .Dv SIGEV_THREAD_ID
84 notifications,
85 the signal specified in
86 .Fa notification->sigev_signo
87 will be sent to the calling process
88 .Pq Dv SIGEV_SIGNO
89 or to the thread whose LWP ID is
90 .Fa notification->sigev_notify_thread_id
91 .Pq Dv SIGEV_THREAD_ID .
92 The information for the queued signal will include:
93 .Bl -column ".Va si_value"
94 .It Sy Member Ta Sy Value
95 .It Va si_code Ta Dv SI_MESGQ
96 .It Va si_value Ta
97 the value stored in
98 .Fa notification->sigev_value
99 .It Va si_mqd Ta Fa mqdes
100 .El
101 .Pp
102 If
103 .Fa notification
104 is
105 .Dv NULL
106 and the process is currently registered for notification by the specified
107 message queue, the existing registration will be removed.
108 .Pp
109 When the notification is sent to the registered process, its registration
110 is removed.
111 The message queue then is available for registration.
112 .Pp
113 If a process has registered for notification of message arrival at a
114 message queue and some thread is blocked in
115 .Fn mq_receive
116 waiting to receive a message when a message arrives at the queue, the
117 arriving message will satisfy the appropriate
118 .Fn mq_receive .
119 The resulting behavior is as if the message queue remains empty, and no
120 notification will be sent.
121 .Sh RETURN VALUES
122 .Rv -std
123 .Sh ERRORS
124 The
125 .Fn mq_notify
126 system call
127 will fail if:
128 .Bl -tag -width Er
129 .It Bq Er EBADF
130 The
131 .Fa mqdes
132 argument is not a valid message queue descriptor.
133 .It Bq Er EBUSY
134 Process is already registered for notification by the message queue.
135 .It Bq Er EINVAL
136 The asynchronous notification method in
137 .Fa notification->sigev_notify
138 is invalid or not supported.
139 .El
140 .Sh SEE ALSO
141 .Xr mq_open 2 ,
142 .Xr mq_send 2 ,
143 .Xr mq_timedsend 2 ,
144 .Xr sigevent 3 ,
145 .Xr siginfo 3
146 .Sh STANDARDS
147 The
148 .Fn mq_notify
149 system call conforms to
150 .St -p1003.1-2004 .
151 .Sh HISTORY
152 Support for
153 .Tn POSIX
154 message queues first appeared in
155 .Fx 7.0 .
156 .Sh COPYRIGHT
157 Portions of this text are reprinted and reproduced in electronic form
158 from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
159 Portable Operating System Interface (POSIX), The Open Group Base
160 Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
161 Electrical and Electronics Engineers, Inc and The Open Group.  In the
162 event of any discrepancy between this version and the original IEEE and
163 The Open Group Standard, the original IEEE and The Open Group Standard is
164 the referee document.  The original Standard can be obtained online at
165 http://www.opengroup.org/unix/online.html.