1 .\" $NetBSD: msgsnd.2,v 1.20 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 send a message to a message queue
43 .Fn msgsnd "int msqid" "const void *msgp" "size_t msgsz" "int msgflg"
47 function sends a message from the message queue specified in
51 argument is a pointer to a user-defined structure containing the message.
52 This structure must contain a first field of type
54 that will indicate the user-defined type of the message.
55 The remaining fields will contain the contents of the message.
56 The following is an example of what this user-defined
57 structure might look like:
58 .Bd -literal -offset indent
60 long mtype; /* message type */
61 char mtext[1]; /* body of message */
67 field is an integer greater than 0 that can
68 be used for selecting messages (see
72 field is an array of bytes of length
74 with size up to the system limit
77 If the number of bytes already on the message queue plus
79 is greater than the maximum number of bytes in the message queue
83 or if the number of messages on all queues system-wide is already equal to
86 determines the action of
92 mask set in it, the call will return immediately.
97 set in it, the call will block until:
98 .Bl -bullet -offset indent
100 The condition which caused the call to block no longer exists.
101 The message was sent.
103 The message queue is removed, in which case \-1 will be returned and
108 The caller catches a signal.
109 The call returns with
115 After a successful call, the data structure associated with the message
116 queue is updated in the following way:
117 .Bl -bullet -offset indent
123 is set to the pid of the calling process.
126 is set to the current time.
129 Upon successful completion, 0 is returned.
130 Otherwise, \-1 is returned and
132 is set to indicate the error.
138 The calling process does not have write access to the message queue.
140 There was no space for this message either on the queue or in the whole
147 points to an invalid address.
149 The system call was interrupted by the delivery of a signal.
153 argument is not a valid message queue identifier,
158 The message queue was removed while
160 was waiting for a resource to become available in order to deliver the
165 argument is greater than
177 system call conforms to
182 Message queues appeared in the first release of