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()returns0. clean. slayed. β¨ - On error, it returns
-1, anderrnois 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
- Copyright 2006, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms