MQ_SEND(3P)
π mq_send(3P) β the POSIX Programmer's Manual, bestie edition
okay so this is mq_send(3P), straight out of the POSIX Programmer's Manual π
π¨ PROLOG (read this first, fr)
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
no cap, that's the whole warning. check your platform before you go feral π«Ά
β¨ NAME β¨
mq_send, mq_timedsend β send a message to a message queue (REALTIME)
π SYNOPSIS π
#include <mqueue.h>
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned msg_prio);
#include <mqueue.h>
#include <time.h>
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned msg_prio, const struct timespec *abstime);
two icons, two headers, one vibe π
πΈ DESCRIPTION πΈ
so mq_send() shall add the message pointed to by the argument msg_ptr to the message queue specified by mqdes. the msg_len argument is the length of that message, in bytes, pointed to by msg_ptr. and heads up: the value of msg_len shall be less than or equal to the mq_msgsize attribute of the message queue, or mq_send() shall fail. like, it's giving strict. π₯
if the message queue isn't full, mq_send() shall behave as if the message is inserted into the queue at the position indicated by the msg_prio argument. a message with a larger numeric value of msg_prio shall be inserted before messages with lower values of msg_prio. and a message shall be inserted after other messages in the queue, if any, with equal msg_prio. (tie goes to whoever got there first, so polite π₯°) the value of msg_prio shall be less than {MQ_PRIO_MAX}.
now the blocking bit π if the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes, mq_send() shall block until space becomes available to enqueue the message, or until mq_send() is interrupted by a signal. if more than one thread is waiting to send when space becomes available in the message queue and the Priority Scheduling option is supported, then the thread of the highest priority that has been waiting the longest shall be unblocked to send its message. otherwise, it is unspecified which waiting thread is unblocked. π
and if the queue is full and O_NONBLOCK is set in the message queue description associated with mqdes, the message shall not be queued and mq_send() shall return an error. no queueing, no waiting, just no. π
mq_timedsend() shall add a message to the message queue specified by mqdes in the manner defined for the mq_send() function. however β and this is the glow-up β if the specified message queue is full and O_NONBLOCK is not set in the message queue description associated with mqdes, the wait for sufficient room in the queue shall be terminated when the specified timeout expires. if O_NONBLOCK is set in the message queue description, this function shall be equivalent to mq_send(). periodt. β
the timeout shall expire when the absolute time specified by abstime passes, as measured by the clock on which timeouts are based (that is, when the value of that clock equals or exceeds abstime), or if the absolute time specified by abstime has already been passed at the time of the call.
the timeout shall be based on the CLOCK_REALTIME clock. π the resolution of the timeout shall be the resolution of the clock on which it is based. the timespec argument is defined in the <time.h> header.
and under no circumstance shall the operation fail with a timeout if there is sufficient room in the queue to add the message immediately. the validity of the abstime parameter need not be checked when there is sufficient room in the queue. iykyk π§
π¦ RETURN VALUE π¦
upon successful completion, the mq_send() and mq_timedsend() functions shall return a value of zero. otherwise, no message shall be enqueued, the functions shall return -1, and errno shall be set to indicate the error. that's the whole deal, bestie π
π ERRORS π
the mq_send() and mq_timedsend() functions shall fail if:
EAGAINβ theO_NONBLOCKflag is set in the message queue description associated withmqdes, and the specified message queue is full.EBADFβ themqdesargument is not a valid message queue descriptor open for writing.EINTRβ a signal interrupted the call tomq_send()ormq_timedsend().EINVALβ the value ofmsg_priowas outside the valid range.EINVALβ the process or thread would have blocked, and theabstimeparameter specified a nanoseconds field value less than zero or greater than or equal to1000 million.EMSGSIZEβ the specified message length,msg_len, exceeds the message size attribute of the message queue.ETIMEDOUTβ theO_NONBLOCKflag was not set when the message queue was opened, but the timeout expired before the message could be added to the queue.
(yeah, EINVAL shows up twice. it's giving overachiever. both are real, both are listed, don't come for me π)
The following sections are informative.
π EXAMPLES π
None.
literally none. iconic of them honestly π
π APPLICATION USAGE π
the value of the symbol {MQ_PRIO_MAX} limits the number of priority levels supported by the application. message priorities range from 0 to {MQ_PRIO_MAX}-1. so like, zero through one-less-than-max, don't forget the minus one, that's the classic off-by-one trap bestie πͺ€
β RATIONALE β
None.
π FUTURE DIRECTIONS π
None.
π₯ SEE ALSO π₯
mq_open()mq_receive()mq_setattr()time()
the Base Definitions volume of POSIX.1β2017, <mqueue.h>, <time.h> πΈ
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie π«Ά this one was IEEE/The Open Group, 2017 β go forth and enqueue responsibly, mwah πβ¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms