1 .\" $NetBSD: msgrcv.2,v 1.1 1995/10/16 23:49:20 jtc 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.
32 .\" $FreeBSD: src/lib/libc/gen/msgrcv.3,v 1.8.2.7 2003/03/15 15:11:05 trhodes Exp $
39 .Nd receive a message from a message queue
47 .Fn msgrcv "int msqid" "void *msgp" "size_t msgsz" "long msgtyp" "int msgflg"
51 system call receives a message from the message queue specified in
53 and places it into the structure pointed to by
55 This structure should consist of the following members:
57 long mtype; /* message type */
58 char mtext[1]; /* body of message */
62 is an integer greater than 0 that can be used for selecting messages,
64 is an array of bytes, with a size up to that of the system limit
69 has one of the following meanings:
76 The first message of type
84 The first message on the queue will be received.
90 The first message of the lowest message type that is
91 less than or equal to the absolute value of
99 specifies the maximum length of the requested message.
101 message has a length greater than
103 it will be silently truncated if the
107 otherwise an error will be returned.
109 If no matching message is present on the message queue specified by
113 depends on whether the
122 will immediately return a value of -1, and set
128 is not set, the calling process will be blocked
132 A message of the requested type becomes available on the message queue.
134 The message queue is removed, in which case -1 will be returned, and
139 A signal is received and caught.
146 If a message is successfully received, the data structure associated with
148 is updated as follows:
152 is decremented by the size of the message.
155 is set to the pid of the caller.
158 is set to the current time.
164 Upon successful completion,
166 returns the number of bytes received into the
168 field of the structure pointed to by
170 Otherwise, -1 is returned, and
172 set to indicate the error.
174 The XSI Interprocess Communication family of functions is also available
175 as an implementation in userspace.
178 daemon has to be running.
182 variable is set in a process' environment, the process and its children
183 will use the userspace implementation.
187 system call will fail if:
193 is not a valid message queue identifier.
195 The message queue was removed while
197 was waiting for a message of the requested type to become available on it.
204 A matching message was received, but its size was greater than
211 The calling process does not have read access to the message queue.
216 points to an invalid address.
218 The system call was interrupted by the delivery of a signal.
220 There is no message of the requested type available on the message queue,
231 Message queues appeared in the first release of
237 specific userspace implementation (see
248 error value, which should be used in
249 the case of a removed message queue, nor the
252 should be used when no suitable message is available and