MQ_GETATTR(2)
π mq_getattr β bestie edition π
okay so you found the manpage for mq_getattr(2) β that's the system calls manual section, and it's all about the POSIX realtime message queue vibe. let's get into it π
β¨ NAME β¨
mq_getattr β get message queue attributes (REALTIME)
π LIBRARY π
POSIX Real-time Library (librt, -lrt)
like, you gotta link it, bestie. -lrt. don't forget or it's giving undefined reference π
πΈ SYNOPSIS πΈ
#include <mqueue.h>
int
mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
π DESCRIPTION π
so the mq_getattr() system call grabs status info and attributes for two things at once, lowkey:
- the message queue itself
- the open message queue description that's chillin' with the message queue descriptor
the mqdes argument is your message queue descriptor. that's the one.
and the results? they get handed back in the mq_attr structure that mqstat points at. iconic.
on return, these members carry the values tied to the open message queue description β as they were set when the queue was opened, and as modified by any mq_setattr() calls that happened after:
mq_flags
and these attributes of the message queue come back exactly as they were set at message queue creation:
mq_maxmsgmq_msgsize
also, on return, this member inside the mq_attr structure that mqstat points at gets set to the current state of the message queue:
mq_curmsgsβ the number of messages currently on the queue.
so basically one call, three different flavours of info. main character energy honestly π
π₯ RETURN VALUES π₯
slayed successfully? you get 0 back. periodt.
anything else and you get -1, plus the global variable errno gets set to tell you what went wrong. so check errno, bestie, it's literally right there π«Ά
π ERRORS π
the mq_getattr() system call will fail if:
[EBADF]β themqdesargument is not a valid message queue descriptor.
that's the whole list. just the one. if your descriptor's fake, it's over π«
π SEE ALSO π
go read those next, they're all in the same little friend group π¦
β STANDARDS β
the mq_getattr() system call conforms to IEEE Std 1003.1-2004 (βPOSIX.1β). certified, no cap.
π HISTORY π
support for POSIX message queues first appeared in FreeBSD 7.0. vintage, but make it realtime π
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. if there's ever 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.
like, the IEEE said it first, we're just quoting the queen π
and that's the whole page!! this one's from Debian, dated February 21, 2014 β mwah, go check your queue attributes bestie, ily πΈβ¨π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
- Copyright (C) 2001-2004 by the Institute of
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms