mq_close(3)

✨ mq_close β€” bestie, let's close that message queue descriptor πŸ’…

okay so first things first: this is mq_close(3) from the Library Functions Manual, and it's lowkey one of the most satisfying lil functions in the whole POSIX lineup. It's giving cleanup era. Let's get into it 🫢


🌸 LIBRARY 🌸

She lives in the real-time library, aka librt, so when you're linking you're gonna want -lrt. Don't forget it, bestie, or the linker will simply not know her 😭


✨ SYNOPSIS ✨

#include <mqueue.h>

int mq_close(mqd_t mqdes);

that's it. that's the whole vibe. one include, one function, one descriptor. iconic πŸŽ€


πŸ‘‘ DESCRIPTION πŸ‘‘

mq_close() closes the message queue descriptor mqdes. boom. done. you're welcome πŸ’…

But wait, there's lore: if the calling process has attached a notification request to this message queue via mqdes β€” and the notification request situation is a whole thing, see mq_notify(3) β€” then that request gets removed, and now another process can attach a notification request of its own. So it's not just closing a door, it's freeing up the door for someone else. very generous of you, fr fr 🌈


πŸ’– RETURN VALUE πŸ’–

  • On success, mq_close() returns 0. clean. slayed. ✨
  • On error, it returns -1, and errno is set to tell you what went wrong. rude but informative πŸ’€

😭 ERRORS 😭

  • EBADF β€” the message queue descriptor specified in mqdes is invalid. like, girl, that descriptor doesn't exist. it's not real. vibe check failed πŸ™ˆ

πŸ¦‹ ATTRIBUTES πŸ¦‹

okay so the terms used in this section are explained over in attributes(7) if you wanna go read up, but here's the tea:

  • Interface: mq_close() β€” Attribute: Thread safety β€” Value: MT-Safe πŸ‘‘

so yes bestie, she is MT-Safe, multiple threads can call her and it's all fine, no cap 🧚


🌟 STANDARDS 🌟

POSIX.1-2008. she's standardized, she's official, she's certified main character energy ⭐


πŸ“œ HISTORY πŸ“œ

POSIX.1-2001.</purpose> β€” yeah she's been around. vintage. classic. still serving πŸ’œ


πŸ“ NOTES πŸ“

  • All open message queues are automatically closed when the process terminates. so if you forget, the OS handles it. she's got you 🫢
  • They're also all automatically closed upon execve(2). surprise cleanup, love that for you ✨

🌈 SEE ALSO 🌈

go read those too, they're all part of the mq cinematic universe πŸŽ€


and that's the whole page, bestie!! this was Linux man-pages 6.20, dated 2026-02-08, and it's the mq_close(3) manual page. go close a descriptor, you absolute legend. mwah πŸ’–πŸ’…βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms