MQ_UNLINK(3POSIX)

πŸ’– PROLOG πŸ’–

ok so this page is part of the POSIX Programmer's Manual β€” we're in MQ_UNLINK(3POSIX) territory, bestie, the POSIX programmer's corner of the man page universe 🌸

heads up tho: the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. vibe check your platform first, fr fr.


✨ NAME ✨

mq_unlink β€” remove a message queue (REALTIME) πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <mqueue.h>

int mq_unlink(const char *name);

like. that's it. one function. one argument. iconic behavior.


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so mq_unlink() shall remove the message queue named by the string name. bye bestie πŸ‘‹

but here's the twist: if one or more processes have that message queue open when mq_unlink() gets called, then the destruction of the message queue shall be postponed until all references to it have been closed. the queue is basically on read receipt πŸ’€ it's not gone until everyone lets go.

but also: the mq_unlink() call need not block until all references have been closed β€” it may return immediately. so it can just dip and let the queue ghost everyone.

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 means:

  • mq_open() will fail if O_CREAT is not set, or
  • it will create a new message queue if O_CREAT is set.

it's giving "fresh start, who dis" ✨


πŸ”₯ RETURN VALUE πŸ”₯

  • Upon successful completion, 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. not slay 😭

πŸ’€ ERRORS πŸ’€

The mq_unlink() function shall fail if:

  • EACCES β€” Permission is denied to unlink the named message queue. rude.
  • 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. interrupted mid-vibe, so valid honestly.
  • ENOENT β€” The named message queue does not exist. it's not there bestie, never was πŸ™ˆ

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 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.
important little footnote energy: 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 once, don't come for it now πŸ’…

The following sections are informative.


🌈 EXAMPLES 🌈

None. (yes literally none, the standard said "no examples, figure it out" 🫢)


🌸 APPLICATION USAGE 🌸

None. (again! nothing here! the vibes are minimal and we respect it)


⭐ RATIONALE ⭐

None. (they really said "no thoughts, head empty" on this one)


🧚 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. it could get a glow-up. watch this space πŸ‘€


πŸ’œ 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 .


and that's the whole page bestie!! 🫢✨ this one came to you courtesy of IEEE/The Open Group, dated 2017, page MQ_UNLINK(3POSIX) β€” go forth and unlink responsibly πŸ’–πŸŽ€πŸ¦‹