mq_unlink(2)

mq_unlink2

Mq_unlink - remove a message queue (realtime)

Usage

#include <mqueue.h>

int

mq_unlink(const char *name);

Library

library “librt”

Overview

The mq_unlink() function removes the message queue named by the string name. If one or more processes have the message queue open when mq_unlink() is called, destruction of the message queue will be postponed until all references to the message queue have been closed. However, the mq_unlink() call need not block until all references have been closed; it may return immediately.

After a successful call to mq_unlink(), reuse of the name will subsequently cause mq_open(2) to behave as if no message queue of this name exists.

Return values

The mq_unlink() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Errors

The mq_unlink() system call will fail if:

[EACCESS]

Permission is denied to unlink the message queue represented by name.

[EINVAL]

name is invalid.

[ENAMETOOLONG]

The length of the name argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.

[ENOENT]

The message queue does not exist.

[ENOSYS]

mqueuefs(4) module is neither loaded nor included in the kernel.

Releases

9 releases since FreeBSD 14.0-RELEASE; the text changed 1 time.

  1. 14.0–14.5
  2. 15.0–16.0

Standards

The mq_unlink() system call conforms to IEEE Std 1003.1-2004 (“POSIX.1”). The [EACCESS] error code is an extension to the standard.

History

Support for POSIX message queues first appeared in FreeBSD 7.0.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.