mq_getfd_np(3)

mq_getfd_np3

Get a file descriptor for an open message queue descriptor

Usage

library “librt”

#include <mqueue.h>

int

mq_getfd_np(mqd_t mqd);

Overview

The mq_getfd_np function retrieves the underlying file descriptor from the given message queue descriptor returned from mq_open(2). The file descriptor is used by other functions to refer to that message queue. The mqd argument must be an open message queue descriptor.

Implementation notes

FreeBSD implements retrieval or alteration of message queue attributes based on the file descriptor. The open file descriptor is copied into a child after fork(2). The fstat(2), fchmod(2), and fchown(2) system calls are supported for the file descriptor.

The file descriptor is safe to use so long as the message queue descriptor remains open.

Return values

Upon successful completion, the function returns a file descriptor.

Errors

The mq_getfd_np function does not return any errors.

Releases

Unchanged in 3 releases since FreeBSD 14.5-RELEASE.

  1. 14.5–16.0

History

Support for the mq_getfd_np function first appeared in FreeBSD 11.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.