MQ_CLOSE(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… MQ_CLOSE(2) β€” the system calls manual, bestie edition

ok so this is the manual page for mq_close from the System Calls Manual, and honestly? It's a little icon. Let me walk you through it 🫢


🌸 NAME 🌸

mq_close β€” close a message queue (REALTIME) ✨


πŸŽ€ LIBRARY πŸŽ€

POSIX Real-time Library (librt, -lrt) β€” yeah you gotta link it, don't forget the -lrt or it's giving undefined reference 😭


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <mqueue.h>

int
mq_close(mqd_t mqdes);

that's the whole vibe. one arg, one int back πŸ’œ


✨ DESCRIPTION ✨

okay so the mq_close() system call removes the association between the message queue descriptor, mqdes, and its message queue. that's it. that's the job. lowkey slay.

but here's the part where you gotta pay attention πŸ‘€ β€” the results of using this message queue descriptor after a successful return from this mq_close(), and until the return of this message queue descriptor from a subsequent mq_open(), are undefined. like, undefined undefined. don't do it. not even a little. πŸ’€

and also β€” if the process has successfully attached a notification request to the message queue via this mqdes, this attachment will be removed, and the message queue becomes available for another process to attach for notification. so you're not just closing, you're also freeing up the notification slot for the next bestie in line 🧚


πŸ”₯ RETURN VALUES πŸ”₯

  • upon successful completion, the value 0 is returned πŸŽ‰
  • otherwise, the value -1 is returned and the global variable errno is set to indicate the error 😭

classic 0-or--1 situation, no cap.


🌈 ERRORS 🌈

the mq_close() system call will fail if:

  • [EBADF] β€” the mqdes argument is not a valid message queue descriptor. that's the only one. that's the whole list. it's a one-error icon πŸ‘‘

πŸ‘‘ SEE ALSO πŸ‘‘

go read those next, iykyk πŸ“š


⭐ STANDARDS ⭐

the mq_close() system call conforms to IEEE Std 1003.1-2004 (β€œPOSIX.1”). certified. official. periodt πŸ’…


πŸ“ HISTORY πŸ“

support for POSIX message queues first appeared in FreeBSD 7.0. vintage fr fr πŸ•°οΈ


bestie this part is the legal one so i'm keeping it exactly as written, no edits, no vibes, we do not mess with the legal text πŸ™ˆ:

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 page!! πŸ’œ this beauty is from Debian, dated November 29, 2005, so she's been slaying since before some of us could read πŸŽ€ mwah, go close a queue responsibly πŸ¦‹βœ¨

πŸ“¦ where this page comes from