MQ_GETATTR(3POSIX)

πŸ’– MQ_GETATTR πŸ’– β€” from the POSIX Programmer's Manual, bestie

okay so first thing, real talk: this page lives in the POSIX Programmer's Manual. The Linux version of this interface might act different (so go check the Linux man page for the deets on Linux behavior), or honestly it might not even be implemented on Linux at all. πŸ™ˆ


✨ NAME ✨

mq_getattr β€” get message queue attributes (REALTIME) πŸŽ€


🌸 SYNOPSIS 🌸

#include <mqueue.h>

int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the mq_getattr() function obtains status information and attributes of the message queue and the open message queue description that's associated with the message queue descriptor. Like, it's giving you the receipts on your queue. 🧾✨

The mqdes argument specifies a message queue descriptor. That's your lil handle to the queue. 🫢

The results get returned in the mq_attr structure referenced by the mqstat argument.

Once it comes back, these members are gonna have the values tied to the open message queue description β€” set when the message queue was opened, and then modified by any subsequent mq_setattr() calls:

  • mq_flags

And these attributes of the message queue come back as they were set at message queue creation:

  • mq_maxmsg
  • mq_msgsize

Then, upon return, this member inside the mq_attr structure referenced by mqstat gets set to the current state of the message queue:

mq_curmsgs

The number of messages currently on the queue. That's it, that's the whole thing. πŸ’…


⭐ RETURN VALUE ⭐

If everything goes off without a hitch, mq_getattr() shall return zero. 😌

Otherwise? It returns -1 and sets errno to tell you what went wrong. not the vibe. 😭


πŸ’€ ERRORS πŸ’€

The mq_getattr() function may fail if:

  • EBADF β€” the mqdes argument is not a valid message queue descriptor. bestie that's not a real queue, that's a fake ID. 🚫
Heads up: the following sections are informative β€” they're the bonus content, not the requirements. πŸ“

🌈 EXAMPLES 🌈

See mq_notify(). (yes really, that's the whole example, go look πŸ‘€)


πŸŽ€ APPLICATION USAGE πŸŽ€

None. (iconic of them tbh, nothing to add πŸ’…)


🧚 RATIONALE 🧚

None.


πŸ“ FUTURE DIRECTIONS πŸ“

None.


πŸ‘‘ SEE ALSO πŸ‘‘

  • mq_notify()
  • mq_open()
  • mq_send()
  • mq_setattr()
  • msgctl()
  • msgget()
  • msgrcv()
  • msgsnd()

Also the Base Definitions volume of POSIX.1‐2017: <mqueue.h> πŸ“š


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!! πŸ’–βœ¨ written up by IEEE/The Open Group, dated 2017, and it's the MQ_GETATTR(3POSIX) page in the POSIX Programmer's Manual. slay, go read your queue attributes, periodt. πŸŽ€πŸ¦‹πŸ‘‘