MQ_SETATTR(2)
π mq_setattr(2) β the manual page, but make it slay π
okay bestie, pull up a chair, we're doing a system call manual page and honestly? it's a short one, we love a short one. this is mq_setattr(2) from the System Calls Manual, and it's giving "small function, big responsibilities." let's get into it. π¦
β¨ NAME β¨
mq_setattr β set message queue attributes (REALTIME)
like... the name literally tells you everything. you're setting attributes. on a message queue. and it's a REALTIME thing, capital letters, very serious, very demure. π
π LIBRARY π
POSIX Real-time Library (librt, -lrt)
so when you link this bad boy you need -lrt, no cap. that's the POSIX Real-time Library, and it's where all the realtime queue girlies hang out. π
πΈ SYNOPSIS πΈ
#include <mqueue.h>
int
mq_setattr(mqd_t mqdes, const struct mq_attr *restrict mqstat,
struct mq_attr *restrict omqstat);
yes the restrict keywords are there, yes they matter, no we are not removing them. this is the exact signature, character for character, bestie. β
π DESCRIPTION π
so the mq_setattr() system call sets attributes associated with the open message queue description referenced by the message queue descriptor specified by mqdes. (say that five times fast, i dare you π)
the message queue attributes corresponding to the following members defined in the mq_attr structure will be set to the specified values upon successful completion of mq_setattr():
mq_flagsβ the value of this member is zero orO_NONBLOCK. that's it. that's the whole vibe. it's either0orO_NONBLOCK, pick your fighter. π
and now the plot twist: the values of the mq_maxmsg, mq_msgsize, and mq_curmsgs members of the mq_attr structure are ignored by mq_setattr(). like, fully ignored. ghosted. not even read. so don't come in here thinking you can sneak a change past those three, because you cannot, they're literally not looking. π
π«Ά RETURN VALUES π«Ά
upon successful completion, the function returns a value of zero and the attributes of the message queue will have been changed as specified. iconic. no notes. β¨
otherwise? the message queue attributes are unchanged, and the function returns a value of -1 and sets the global variable errno to indicate the error. so nothing got touched, and errno is here to tell you why. she's a messenger, not a hater. π§
π¨ ERRORS π¨
the mq_setattr() system call will fail if:
[EBADF]β themqdesargument is not a valid message queue descriptor.
that's the only one listed, bestie. one single error. a minimalist. a queen of efficiency. π
π₯ SEE ALSO π₯
go read those next, they're all part of the same friend group. iykyk. π
π STANDARDS π
the mq_setattr() system call conforms to IEEE Std 1003.1-2004 ("POSIX.1"). certified. compliant. we love a standards-abiding function. π
π°οΈ HISTORY π°οΈ
support for POSIX message queues first appeared in FreeBSD 7.0. throwback era, honestly. a little retro moment. π
βοΈ 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. 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.
yes we have to include the whole copyright paragraph, bestie. the legal girlies are watching. do not skip it. π
and that's the whole page!! this one came from Debian, dated May 17, 2011 β a little vintage moment, but she still serves. bye bestie, go set some attributes, you're gonna do amazing. ππ¦β¨
π¦ 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