MQ_UNLINK(3P)

๐Ÿ’– PROLOG ๐Ÿ’–

Okay so real talk first, bestie. This manual page is part of the POSIX Programmer's Manual. But here's the tea: the Linux implementation of this interface may differ (so like, go consult the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux at all. Vibe check your system first, fr fr. ๐Ÿซถ


โœจ NAME โœจ

mq_unlink โ€” remove a message queue (REALTIME)


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <mqueue.h>

int mq_unlink(const char *name);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So the mq_unlink() function shall remove the message queue named by the string name. That's the whole job. Iconic. ๐Ÿ’…

But wait, plot twist ๐Ÿ‘€ โ€” if one or more processes have the message queue open when mq_unlink() gets called, then destruction of the message queue gets postponed until all references to the message queue have been closed. It's giving "I'm leaving but I'm not leaving until everyone stops texting me" energy. And here's the thing: the mq_unlink() call need not block until all references have been closed โ€” it may return immediately. So it's not sitting there waiting for the group chat to go quiet, it can just dip. ๐Ÿƒโ€โ™€๏ธ๐Ÿ’จ

Then, after a successful call to mq_unlink(), reuse of the name shall subsequently cause mq_open() to behave as if no message queue of this name exists โ€” that is, mq_open() will fail if O_CREAT is not set, or will create a new message queue if O_CREAT is set. Fresh start, new name, who dis. โœจ


๐Ÿ’œ RETURN VALUE ๐Ÿ’œ

When it goes right, the function shall return a value of zero. Slay.

Otherwise? The named message queue shall be unchanged by this function call, and the function shall return a value of -1 and set errno to indicate the error. So nothing happened, and it told you why. Honest queen. ๐Ÿ˜ญ


๐Ÿ”ฅ ERRORS ๐Ÿ”ฅ

The mq_unlink() function shall fail if:

  • EACCES โ€” Permission is denied to unlink the named message queue. Not your queue, not your call, bestie. ๐Ÿ™ˆ
  • EINTR โ€” The call to mq_unlink() blocked waiting for all references to the named message queue to be closed, and a signal interrupted the call. Rude interruption, honestly. ๐Ÿ’€
  • ENOENT โ€” The named message queue does not exist. It's not there. Never was. Ghosted. ๐Ÿ‘ป

The mq_unlink() function may fail if:

  • ENAMETOOLONG โ€” The length of the name argument exceeds {_POSIX_PATH_MAX} on systems that do not support the XSI option, or exceeds {_XOPEN_PATH_MAX} on XSI systems, or the name has a pathname component that is longer than {_POSIX_NAME_MAX} on systems that do not support the XSI option, or longer than {_XOPEN_NAME_MAX} on XSI systems. BUT โ€” important little detail, no cap โ€” a call to mq_unlink() with a name argument that contains the same message queue name as was previously used in a successful mq_open() call shall not give an [ENAMETOOLONG] error. So if it worked before, it's not gonna suddenly be "too long" on you. She remembers. ๐Ÿงš
Also just so you know: the following sections are informative. Not rules, just vibes.

๐ŸŒธ EXAMPLES ๐ŸŒธ

None. ๐Ÿ˜ญ I know. Devastating. No examples to serve you today.


๐ŸŒˆ APPLICATION USAGE ๐ŸŒˆ

None. Again. We're running on pure theory here. ๐Ÿซ 


โญ RATIONALE โญ

None. No reasoning given. It just is. Main character energy. ๐Ÿ‘‘


๐Ÿ“ FUTURE DIRECTIONS ๐Ÿ“

A future version might require the mq_open() and mq_unlink() functions to have semantics similar to normal file system operations. So like... watch this space, bestie. Things might change. ๐Ÿ”ฎ


๐ŸŽ€ SEE ALSO ๐ŸŽ€

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

The Base Definitions volume of POSIX.1โ€2017, <mqueue.h>


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 .


Okay that's the whole page, babe โ€” brought to you by IEEE/The Open Group, 2017, MQ_UNLINK(3P) era. Go forth and unlink responsibly. Mwah. ๐Ÿ’‹โœจ

๐Ÿ“ฆ where this page comes from