The man page for the mq_open(2) function fails to state that another possible cause of the return value being set to -1, with error set to EINVAL, is that the call, if permitted, would cause one or another of the following kernel tunable limit parameters to be exceeded: kern.mqueue.maxmq kern.mqueue.maxmsgsize kern.mqueue.maxmsg
I created a Phabricator review for this: https://reviews.freebsd.org/D32517 This documents the error case and the sysctls for mqueue. I'm not sure if this system call page is the right place to document sysctls.
I disagree. As a general matter, all possible causes of syscall failures should be documented on the relevant man page (for the syscall).
As a follow up, here is another failure scenario for mq_open: the kernel module is not loaded. Recent versions of FreeBSD made this a loadable module instead of baked into the kernel image. The mq_open man page should reflect this. I think the error code is ENOSYS or 78 - Function not implemented.
^Triage: while this PR refers to a Phabricator patch, it does not actually have a patch in and of itself.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3e9f4fd6fc50300d052d5619d82a14d3488483d5 commit 3e9f4fd6fc50300d052d5619d82a14d3488483d5 Author: Kit Dallege <xaum.io@gmail.com> AuthorDate: 2026-04-02 17:37:49 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2026-04-02 22:48:52 +0000 mq_open(2): document sysctl limit EINVAL and ENFILE conditions Document two missing error conditions for mq_open(2): - EINVAL: returned when mq_maxmsg exceeds kern.mqueue.maxmsg or mq_msgsize exceeds kern.mqueue.maxmsgsize. - ENFILE: add kern.mqueue.maxmq sysctl name to the existing entry. PR: 243209 Reviewed by: mhorne MFC after: 1 week Signed-off-by: Kit Dallege <xaum.io@gmail.com> Pull Request: https://github.com/freebsd/freebsd-src/pull/2098 lib/libsys/mq_open.2 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=0a5c45744e214275279b97f15b72fc8b9bd4da71 commit 0a5c45744e214275279b97f15b72fc8b9bd4da71 Author: Kit Dallege <xaum.io@gmail.com> AuthorDate: 2026-04-02 17:37:49 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2026-04-16 15:25:07 +0000 mq_open(2): document sysctl limit EINVAL and ENFILE conditions Document two missing error conditions for mq_open(2): - EINVAL: returned when mq_maxmsg exceeds kern.mqueue.maxmsg or mq_msgsize exceeds kern.mqueue.maxmsgsize. - ENFILE: add kern.mqueue.maxmq sysctl name to the existing entry. PR: 243209 Reviewed by: mhorne MFC after: 1 week Signed-off-by: Kit Dallege <xaum.io@gmail.com> Pull Request: https://github.com/freebsd/freebsd-src/pull/2098 (cherry picked from commit 3e9f4fd6fc50300d052d5619d82a14d3488483d5) lib/libsys/mq_open.2 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)