MQ_CLOSE(3P)

🌸 MQ_CLOSE(3P) β€” the POSIX Programmer's Manual one πŸ’–

okay bestie, first things first: this page lives in the POSIX Programmer's Manual, and the manual name is MQ_CLOSE(3P) β€” that's section 3P, the POSIX-flavored section. Say it with me. πŸŽ€

✨ PROLOG ✨ (the lil disclaimer, do not skip)

This manual page is part of the POSIX Programmer's Manual, periodt.

Heads up fr fr: the Linux implementation of this interface may differ β€” so consult the corresponding Linux manual page for details on Linux behavior. And plot twist: the interface may not even be implemented on Linux. πŸ’€ Not me finding that out the hard way.

πŸ‘‘ NAME πŸ‘‘

mq_close β€” close a message queue (REALTIME). That's it, that's the whole name section, she's brief and she's iconic. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <mqueue.h>

int mq_close(mqd_t mqdes);

That's the whole vibe. Include the header, call the function, hand her a mqdes. Easy. ✨


πŸ’œ DESCRIPTION πŸ’œ

So mq_close() shall remove the association between the message queue descriptor, mqdes, and its message queue. Like, you two are no longer linked. It's giving conscious uncoupling. 🫢

⚠️ REAL TALK, WRITE THIS DOWN: the results of using this message queue descriptor after a successful return from this mq_close(), and until that descriptor comes back from a subsequent mq_open(), are undefined. Undefined!! That means nobody promised you anything, bestie. Do not touch it. Do not look at it. Let her go. 😭

And here's the other thing: if the process has successfully attached a notification request to the message queue via this mqdes, then that attachment shall be removed, and the message queue is then available for another process to attach for notification. So you're not just closing β€” you're clearing the runway for the next person. Generous. Main character energy. 🌈


πŸ”₯ RETURN VALUE πŸ”₯

  • On success? She returns a value of zero. Clean. Gorgeous. Slay. πŸ’…
  • Otherwise? She returns a value of -1 and sets errno to indicate the error. Not slay. But informative. πŸ™ˆ

πŸ’… ERRORS πŸ’…

The mq_close() function shall fail if:

  • EBADF β€” the mqdes argument is not a valid message queue descriptor. That descriptor is fake, expired, or just not a descriptor, and the function is NOT having it.

The following sections are informative. (Read: cute bonus content, not the actual rules. πŸŽ€)


🌸 EXAMPLES 🌸

None.

(Not a single one. She said no example era. Respect it.) ✨


🧚 APPLICATION USAGE 🧚

None.

(Nothing to add, bestie. Nothing at all.) πŸ’–


⭐ RATIONALE ⭐

None.

(She didn't feel the need to justify herself. Queen behavior.) πŸ‘‘


🌈 FUTURE DIRECTIONS 🌈

None.

(No plans. No notes. No future arc announced.) πŸ¦‹


🫢 SEE ALSO 🫢

Go read these next, they're all in the group chat:

  • mq_open()
  • mq_unlink()
  • msgctl()
  • msgget()
  • msgrcv()
  • msgsnd()

And also: The Base Definitions volume of POSIX.1‐2017, <mqueue.h> β€” the header itself, iykyk. πŸ’œ


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 πŸ’– go forth and close your message queues responsibly ✨

signed, sealed, and delivered by IEEE/The Open Group, dated 2017 β€” mwah πŸ’…

πŸ“¦ where this page comes from