1*8269e767SBrooks Davis.\" Copyright (c) 2005 David Xu <davidxu@FreeBSD.org> 2*8269e767SBrooks Davis.\" All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 8*8269e767SBrooks Davis.\" notice(s), this list of conditions and the following disclaimer as 9*8269e767SBrooks Davis.\" the first lines of this file unmodified other than the possible 10*8269e767SBrooks Davis.\" addition of one or more copyright notices. 11*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 12*8269e767SBrooks Davis.\" notice(s), this list of conditions and the following disclaimer in 13*8269e767SBrooks Davis.\" the documentation and/or other materials provided with the 14*8269e767SBrooks Davis.\" distribution. 15*8269e767SBrooks Davis.\" 16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 17*8269e767SBrooks Davis.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19*8269e767SBrooks Davis.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE 20*8269e767SBrooks Davis.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*8269e767SBrooks Davis.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*8269e767SBrooks Davis.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23*8269e767SBrooks Davis.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24*8269e767SBrooks Davis.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25*8269e767SBrooks Davis.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26*8269e767SBrooks Davis.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27*8269e767SBrooks Davis.\" 28*8269e767SBrooks Davis.\" Portions of this text are reprinted and reproduced in electronic form 29*8269e767SBrooks Davis.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- 30*8269e767SBrooks Davis.\" Portable Operating System Interface (POSIX), The Open Group Base 31*8269e767SBrooks Davis.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of 32*8269e767SBrooks Davis.\" Electrical and Electronics Engineers, Inc and The Open Group. In the 33*8269e767SBrooks Davis.\" event of any discrepancy between this version and the original IEEE and 34*8269e767SBrooks Davis.\" The Open Group Standard, the original IEEE and The Open Group Standard is 35*8269e767SBrooks Davis.\" the referee document. The original Standard can be obtained online at 36*8269e767SBrooks Davis.\" http://www.opengroup.org/unix/online.html. 37*8269e767SBrooks Davis.\" 38*8269e767SBrooks Davis.Dd November 29, 2005 39*8269e767SBrooks Davis.Dt MQ_SEND 2 40*8269e767SBrooks Davis.Os 41*8269e767SBrooks Davis.Sh NAME 42*8269e767SBrooks Davis.Nm mq_send , mq_timedsend 43*8269e767SBrooks Davis.Nd "send a message to message queue (REALTIME)" 44*8269e767SBrooks Davis.Sh LIBRARY 45*8269e767SBrooks Davis.Lb librt 46*8269e767SBrooks Davis.Sh SYNOPSIS 47*8269e767SBrooks Davis.In mqueue.h 48*8269e767SBrooks Davis.Ft int 49*8269e767SBrooks Davis.Fo mq_send 50*8269e767SBrooks Davis.Fa "mqd_t mqdes" 51*8269e767SBrooks Davis.Fa "const char *msg_ptr" 52*8269e767SBrooks Davis.Fa "size_t msg_len" 53*8269e767SBrooks Davis.Fa "unsigned msg_prio" 54*8269e767SBrooks Davis.Fc 55*8269e767SBrooks Davis.Ft int 56*8269e767SBrooks Davis.Fo mq_timedsend 57*8269e767SBrooks Davis.Fa "mqd_t mqdes" 58*8269e767SBrooks Davis.Fa "const char *msg_ptr" 59*8269e767SBrooks Davis.Fa "size_t msg_len" 60*8269e767SBrooks Davis.Fa "unsigned msg_prio" 61*8269e767SBrooks Davis.Fa "const struct timespec *abs_timeout" 62*8269e767SBrooks Davis.Fc 63*8269e767SBrooks Davis.Sh DESCRIPTION 64*8269e767SBrooks DavisThe 65*8269e767SBrooks Davis.Fn mq_send 66*8269e767SBrooks Davissystem call adds the message pointed to by the argument 67*8269e767SBrooks Davis.Fa msg_ptr 68*8269e767SBrooks Davisto the message queue specified by 69*8269e767SBrooks Davis.Fa mqdes . 70*8269e767SBrooks DavisThe 71*8269e767SBrooks Davis.Fa msg_len 72*8269e767SBrooks Davisargument specifies the length of the message, in bytes, pointed to by 73*8269e767SBrooks Davis.Fa msg_ptr . 74*8269e767SBrooks DavisThe value of 75*8269e767SBrooks Davis.Fa msg_len 76*8269e767SBrooks Davisshould be less than or equal to the 77*8269e767SBrooks Davis.Va mq_msgsize 78*8269e767SBrooks Davisattribute of the message queue, or 79*8269e767SBrooks Davis.Fn mq_send 80*8269e767SBrooks Daviswill fail. 81*8269e767SBrooks Davis.Pp 82*8269e767SBrooks DavisIf the specified message queue is not full, 83*8269e767SBrooks Davis.Fn mq_send 84*8269e767SBrooks Daviswill behave as if the message is inserted into the message queue at 85*8269e767SBrooks Davisthe position indicated by the 86*8269e767SBrooks Davis.Fa msg_prio 87*8269e767SBrooks Davisargument. 88*8269e767SBrooks DavisA message with a larger numeric value of 89*8269e767SBrooks Davis.Fa msg_prio 90*8269e767SBrooks Daviswill be inserted before messages with lower values of 91*8269e767SBrooks Davis.Fa msg_prio . 92*8269e767SBrooks DavisA message will be inserted after other messages in the queue, if any, 93*8269e767SBrooks Daviswith equal 94*8269e767SBrooks Davis.Fa msg_prio . 95*8269e767SBrooks DavisThe value of 96*8269e767SBrooks Davis.Fa msg_prio 97*8269e767SBrooks Davisshould be less than 98*8269e767SBrooks Davis.Brq Dv MQ_PRIO_MAX . 99*8269e767SBrooks Davis.Pp 100*8269e767SBrooks DavisIf the specified message queue is full and 101*8269e767SBrooks Davis.Dv O_NONBLOCK 102*8269e767SBrooks Davisis not set in the message queue description associated with 103*8269e767SBrooks Davis.Fa mqdes , 104*8269e767SBrooks Davis.Fn mq_send 105*8269e767SBrooks Daviswill block until space becomes available to enqueue the 106*8269e767SBrooks Davismessage, or until 107*8269e767SBrooks Davis.Fn mq_send 108*8269e767SBrooks Davisis interrupted by a signal. 109*8269e767SBrooks DavisIf more than one thread is 110*8269e767SBrooks Daviswaiting to send when space becomes available in the message queue and 111*8269e767SBrooks Davisthe Priority Scheduling option is supported, then the thread of the 112*8269e767SBrooks Davishighest priority that has been waiting the longest will be unblocked 113*8269e767SBrooks Davisto send its message. 114*8269e767SBrooks DavisOtherwise, it is unspecified which waiting thread 115*8269e767SBrooks Davisis unblocked. 116*8269e767SBrooks DavisIf the specified message queue is full and 117*8269e767SBrooks Davis.Dv O_NONBLOCK 118*8269e767SBrooks Davisis set in the message queue description associated with 119*8269e767SBrooks Davis.Fa mqdes , 120*8269e767SBrooks Davisthe message will not be queued and 121*8269e767SBrooks Davis.Fn mq_send 122*8269e767SBrooks Daviswill return an error. 123*8269e767SBrooks Davis.Pp 124*8269e767SBrooks DavisThe 125*8269e767SBrooks Davis.Fn mq_timedsend 126*8269e767SBrooks Davissystem call will add a message to the message queue specified by 127*8269e767SBrooks Davis.Fa mqdes 128*8269e767SBrooks Davisin the manner defined for the 129*8269e767SBrooks Davis.Fn mq_send 130*8269e767SBrooks Davissystem call. 131*8269e767SBrooks DavisHowever, if the specified message queue is full and 132*8269e767SBrooks Davis.Dv O_NONBLOCK 133*8269e767SBrooks Davisis not set in the message queue description associated with 134*8269e767SBrooks Davis.Fa mqdes , 135*8269e767SBrooks Davisthe wait for sufficient room in the queue will be terminated when 136*8269e767SBrooks Davisthe specified timeout expires. 137*8269e767SBrooks DavisIf 138*8269e767SBrooks Davis.Dv O_NONBLOCK 139*8269e767SBrooks Davisis set in the message queue description, this system call is 140*8269e767SBrooks Davisequivalent to 141*8269e767SBrooks Davis.Fn mq_send . 142*8269e767SBrooks Davis.Pp 143*8269e767SBrooks DavisThe timeout will expire when the absolute time specified by 144*8269e767SBrooks Davis.Fa abs_timeout 145*8269e767SBrooks Davispasses, as measured by the clock on which timeouts are based (that is, 146*8269e767SBrooks Daviswhen the value of that clock equals or exceeds 147*8269e767SBrooks Davis.Fa abs_timeout ) , 148*8269e767SBrooks Davisor if the absolute time specified by 149*8269e767SBrooks Davis.Fa abs_timeout 150*8269e767SBrooks Davishas already been passed at the time of the call. 151*8269e767SBrooks Davis.Pp 152*8269e767SBrooks DavisThe timeout is based on the 153*8269e767SBrooks Davis.Dv CLOCK_REALTIME 154*8269e767SBrooks Davisclock. 155*8269e767SBrooks Davis.Sh RETURN VALUES 156*8269e767SBrooks DavisUpon successful completion, the 157*8269e767SBrooks Davis.Fn mq_send 158*8269e767SBrooks Davisand 159*8269e767SBrooks Davis.Fn mq_timedsend 160*8269e767SBrooks Davissystem calls return a value of zero. 161*8269e767SBrooks DavisOtherwise, no message will be 162*8269e767SBrooks Davisenqueued, the system calls return \-1, and 163*8269e767SBrooks Davisthe global variable 164*8269e767SBrooks Davis.Va errno 165*8269e767SBrooks Davisis set to indicate the error. 166*8269e767SBrooks Davis.Sh ERRORS 167*8269e767SBrooks DavisThe 168*8269e767SBrooks Davis.Fn mq_send 169*8269e767SBrooks Davisand 170*8269e767SBrooks Davis.Fn mq_timedsend 171*8269e767SBrooks Davissystem calls 172*8269e767SBrooks Daviswill fail if: 173*8269e767SBrooks Davis.Bl -tag -width Er 174*8269e767SBrooks Davis.It Bq Er EAGAIN 175*8269e767SBrooks DavisThe 176*8269e767SBrooks Davis.Dv O_NONBLOCK 177*8269e767SBrooks Davisflag is set in the message queue description associated with 178*8269e767SBrooks Davis.Fa mqdes , 179*8269e767SBrooks Davisand the specified message queue is full. 180*8269e767SBrooks Davis.It Bq Er EBADF 181*8269e767SBrooks DavisThe 182*8269e767SBrooks Davis.Fa mqdes 183*8269e767SBrooks Davisargument is not a valid message queue descriptor open for writing. 184*8269e767SBrooks Davis.It Bq Er EINTR 185*8269e767SBrooks DavisA signal interrupted the call to 186*8269e767SBrooks Davis.Fn mq_send 187*8269e767SBrooks Davisor 188*8269e767SBrooks Davis.Fn mq_timedsend . 189*8269e767SBrooks Davis.It Bq Er EINVAL 190*8269e767SBrooks DavisThe value of 191*8269e767SBrooks Davis.Fa msg_prio 192*8269e767SBrooks Daviswas outside the valid range. 193*8269e767SBrooks Davis.It Bq Er EINVAL 194*8269e767SBrooks DavisThe process or thread would have blocked, and the 195*8269e767SBrooks Davis.Fa abs_timeout 196*8269e767SBrooks Davisparameter specified a nanoseconds field value less than zero or greater 197*8269e767SBrooks Davisthan or equal to 1000 million. 198*8269e767SBrooks Davis.It Bq Er EMSGSIZE 199*8269e767SBrooks DavisThe specified message length, 200*8269e767SBrooks Davis.Fa msg_len , 201*8269e767SBrooks Davisexceeds the message size attribute of the message queue. 202*8269e767SBrooks Davis.It Bq Er ETIMEDOUT 203*8269e767SBrooks DavisThe 204*8269e767SBrooks Davis.Dv O_NONBLOCK 205*8269e767SBrooks Davisflag was not set when the message queue was opened, but the timeout 206*8269e767SBrooks Davisexpired before the message could be added to the queue. 207*8269e767SBrooks Davis.El 208*8269e767SBrooks Davis.Sh SEE ALSO 209*8269e767SBrooks Davis.Xr mq_open 2 , 210*8269e767SBrooks Davis.Xr mq_receive 2 , 211*8269e767SBrooks Davis.Xr mq_setattr 2 , 212*8269e767SBrooks Davis.Xr mq_timedreceive 2 213*8269e767SBrooks Davis.Sh STANDARDS 214*8269e767SBrooks DavisThe 215*8269e767SBrooks Davis.Fn mq_send 216*8269e767SBrooks Davisand 217*8269e767SBrooks Davis.Fn mq_timedsend 218*8269e767SBrooks Davissystem calls conform to 219*8269e767SBrooks Davis.St -p1003.1-2004 . 220*8269e767SBrooks Davis.Sh HISTORY 221*8269e767SBrooks DavisSupport for 222*8269e767SBrooks Davis.Tn POSIX 223*8269e767SBrooks Davismessage queues first appeared in 224*8269e767SBrooks Davis.Fx 7.0 . 225*8269e767SBrooks Davis.Sh COPYRIGHT 226*8269e767SBrooks DavisPortions of this text are reprinted and reproduced in electronic form 227*8269e767SBrooks Davisfrom IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- 228*8269e767SBrooks DavisPortable Operating System Interface (POSIX), The Open Group Base 229*8269e767SBrooks DavisSpecifications Issue 6, Copyright (C) 2001-2004 by the Institute of 230*8269e767SBrooks DavisElectrical and Electronics Engineers, Inc and The Open Group. In the 231*8269e767SBrooks Davisevent of any discrepancy between this version and the original IEEE and 232*8269e767SBrooks DavisThe Open Group Standard, the original IEEE and The Open Group Standard is 233*8269e767SBrooks Davisthe referee document. The original Standard can be obtained online at 234*8269e767SBrooks Davishttp://www.opengroup.org/unix/online.html. 235