| 1 |
'\" t |
| 2 |
.\" Copyright 2006, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH mq_close 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
mq_close \- close a message queue descriptor |
| 10 |
.SH LIBRARY |
| 11 |
Real-time library |
| 12 |
.RI ( librt ,\~ \-lrt ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <mqueue.h> |
| 16 |
.P |
| 17 |
.BI "int mq_close(mqd_t " mqdes ); |
| 18 |
.fi |
| 19 |
.SH DESCRIPTION |
| 20 |
.BR mq_close () |
| 21 |
closes the message queue descriptor |
| 22 |
.IR mqdes . |
| 23 |
.P |
| 24 |
If the calling process has attached a notification request (see |
| 25 |
.BR mq_notify (3)) |
| 26 |
to this message queue via |
| 27 |
.IR mqdes , |
| 28 |
then this request is removed, |
| 29 |
and another process can now attach a notification request. |
| 30 |
.SH RETURN VALUE |
| 31 |
On success |
| 32 |
.BR mq_close () |
| 33 |
returns 0; |
| 34 |
on error, \-1 is returned, with |
| 35 |
.I errno |
| 36 |
set to indicate the error. |
| 37 |
.SH ERRORS |
| 38 |
.TP |
| 39 |
.B EBADF |
| 40 |
The message queue descriptor specified in |
| 41 |
.I mqdes |
| 42 |
is invalid. |
| 43 |
.SH ATTRIBUTES |
| 44 |
For an explanation of the terms used in this section, see |
| 45 |
.BR attributes (7). |
| 46 |
.TS |
| 47 |
allbox; |
| 48 |
lbx lb lb |
| 49 |
l l l. |
| 50 |
Interface Attribute Value |
| 51 |
T{ |
| 52 |
.na |
| 53 |
.nh |
| 54 |
.BR mq_close () |
| 55 |
T} Thread safety MT-Safe |
| 56 |
.TE |
| 57 |
.SH STANDARDS |
| 58 |
POSIX.1-2008. |
| 59 |
.SH HISTORY |
| 60 |
POSIX.1-2001. |
| 61 |
.SH NOTES |
| 62 |
All open message queues are automatically closed on process termination, |
| 63 |
or upon |
| 64 |
.BR execve (2). |
| 65 |
.SH SEE ALSO |
| 66 |
.BR mq_getattr (3), |
| 67 |
.BR mq_notify (3), |
| 68 |
.BR mq_open (3), |
| 69 |
.BR mq_receive (3), |
| 70 |
.BR mq_send (3), |
| 71 |
.BR mq_unlink (3), |
| 72 |
.BR mq_overview (7) |