MQ_CLOSE(2)
π mq_close β bestie's guide to closing a message queue (REALTIME) π
okay so this is a page from the System Calls Manual, and we're talking about mq_close π
lowkey one of the simplest syscalls you'll ever meet, but she still deserves her moment.
π LIBRARY
POSIX Real-time Library β that's librt, link it with -lrt or she simply will not show up to the function party π«Ά
β¨ SYNOPSIS β¨
#include <mqueue.h>
int
mq_close(mqd_t mqdes);
that's it. that's the whole vibe. one descriptor in, vibes out π
πΈ DESCRIPTION πΈ
so mq_close() is the syscall that removes the association between the message queue descriptor, mqdes, and its message queue. like, she's breaking up with the queue. amicably. no drama. πβ¨
β οΈ ok bestie this part matters: the results of using this message queue descriptor after a successful return from thismq_close(), and until the return of this message queue descriptor from a subsequentmq_open(), are UNDEFINED. not "kinda weird", not "probably fine" β undefined. do not touch her after the breakup. it's giving cursed energy π
now, if the process has successfully attached a notification request to the message queue via this mqdes, then that attachment will be removed, and the message queue becomes available for another process to attach for notification. so like, the queue isn't sad and lonely β she's free to be claimed by someone new. slay for her honestly ππ¦
π RETURN VALUES π
- on success β the value
0comes back. perfect. immaculate. no notes β¨ - otherwise β the value
-1comes back, and the global variableerrnois set to tell you what went wrong π
π ERRORS π
mq_close() will fail if:
[EBADF]β themqdesargument is not a valid message queue descriptor. basically you handed her a fake ID and she noticed. not the move, bestie π
π₯ SEE ALSO π₯
mq_open(2)β the reunion tour π«Άmq_unlink(2)β the actual dramatic goodbye π
π STANDARDS π
mq_close() conforms to IEEE Std 1003.1-2004 (βPOSIX.1β). certified. official. she passed the vibe check β
π§ HISTORY π§
Support for POSIX message queues first appeared in FreeBSD 7.0. so she's been iconic since way back, we love a veteran π
π 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.
and that's the whole page, bestie!! π this Debian edition dropped November 29, 2005 and yes it's still serving. mwah ππβ¨π¦πΈπ
π¦ 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