1 .\" $NetBSD: msgrcv.2,v 1.22 2013/07/24 11:54:04 skrll Exp $
3 .\" Copyright (c) 1995 Frank van der Linden
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed for the NetBSD Project
17 .\" by Frank van der Linden
18 .\" 4. The name of the author may not be used to endorse or promote products
19 .\" derived from this software without specific prior written permission
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .Nd receive a message from a message queue
43 .Fn msgrcv "int msqid" "void *msgp" "size_t msgsz" "long msgtyp" "int msgflg"
47 function receives a message from the message queue specified in
49 and places it into the user-defined structure pointed to by
51 This structure must contain a first field of type
53 that will indicate the user-defined type of the message.
54 The remaining fields will contain the contents of the message.
55 The following is an example of what this user-defined structure might
59 long mtype; /* message type */
60 char mtext[1]; /* body of message */
65 is an integer greater than 0 that can be used to select messages.
67 is an array of bytes, with size up to the system limit
72 has one of the following meanings:
77 The first message of type
83 The first message on the queue will be received.
87 The first message of the lowest message type that is
88 less than or equal to the absolute value of
95 specifies the size in bytes of
97 If the received message has a length greater than
99 it will be silently truncated if the
103 otherwise an error will be returned.
105 If no matching message is present on the message queue specified by
109 depends on whether the
118 will immediately return a value of \-1 and set
124 is not set, the calling process will block until:
127 A message of the requested type becomes available on the message queue.
129 The message queue is removed, in which case \-1 will be returned and
134 A signal is received and caught.
141 If a message is successfully received, the data structure associated with
143 is updated as follows:
147 is set to the pid of the caller.
150 is set to the current time.
156 Upon successful completion,
158 returns the number of bytes received and placed into the
160 field of the structure pointed to by
162 Otherwise, \-1 is returned, and
164 set to indicate the error.
170 A matching message was received, but its size was greater than
177 The calling process does not have read access to the message queue.
179 There is no message of the requested type available on the message queue,
186 points to an invalid address.
188 The message queue identifier
190 is removed from the system.
192 The system call was interrupted by the delivery of a signal.
195 is not a valid message queue identifier
197 The message queue was removed while
199 was waiting for a message of the requested type to become available in it.
205 The queue does not contain a message of the desired type and
216 system call conforms to
219 Message queues appeared in the first release of