MQ_GETFD_NP(3)
π¦ MQ_GETFD_NP(3) β the manual page, bestie edition π¦
okay so this is mq_getfd_np(3) from the Library Functions Manual, and honestly? it's a little cutie. short page, big "wait that's actually useful" energy. let's get into it π
β¨ NAME β¨
mq_getfd_np β get a file descriptor for an open message queue descriptor π
like, you have a message queue descriptor, and you want the actual file descriptor underneath it. that's the whole gig. the vibes are immaculate and the premise is simple. iykyk π«Ά
β¨ SYNOPSIS β¨
she lives in the POSIX Real-time Library (that's librt, link with -lrt), and she needs her header:
#include <mqueue.h>
int
mq_getfd_np(mqd_t mqd);
that's it. one arg. one int coming back. no drama, no cap π
β¨ DESCRIPTION β¨
so the mq_getfd_np function retrieves the underlying file descriptor from the given message queue descriptor β you know, the one you got back from mq_open(2)? yeah, that one. πΈ
and like, what's the fd even for? it's the thing other functions use to refer to that message queue. it's the queue's main character handle, lowkey π
also important, bestie: the mqd argument must be an open message queue descriptor. must be. don't come at her with a closed one π
β¨ IMPLEMENTATION NOTES β¨
okay this part is the FreeBSD lore and it's honestly kind of iconic:
- FreeBSD implements retrieval or alteration of message queue attributes based on the file descriptor. yes, both. she's versatile π
- the open file descriptor gets copied into a child after
fork(2). so your kid process inherits it, periodt. - the
fstat(2),fchmod(2), andfchown(2)system calls are supported for the file descriptor. stat it, chmod it, chown it β she said yes to all three β¨
β οΈ vibe check / safety note, fr fr: the file descriptor is safe to use so long as the message queue descriptor remains open. the moment mqd closes, that fd's whole situation changes and we do NOT want that for you π
β¨ RETURN VALUES β¨
upon successful completion, the function returns a file descriptor. that's it. that's the win. slay π
β¨ ERRORS β¨
the mq_getfd_np function does not return any errors.
not one. zero. she simply doesn't do errors. flawless behavior honestly πβ¨
β¨ SEE ALSO β¨
go read these next, bestie, they're the friend group:
β¨ HISTORY β¨
support for the mq_getfd_np function first appeared in FreeBSD 11.0. a queen since 11.0 ππ
and that's the page!! mwah π huge thank you to the Debian girlies for this one β this edition is dated December 18, 2025, so go forth and get those file descriptors responsibly π«Ά
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 2024 Rick Parrish <unitrunker@unitrunker.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms