[Previous]
[Contents]
[Next]

mq_close()

close a message queue

Synopsis:

#include <mqueue.h>
int mq_close( mqd_t mqdes );

Description:

The mq_close() function removes the association between the message-queue descriptor mqdes and a message queue. If the current process has attached a signal to this queue for notification, this attachment is eliminated.

If this queue has been unlinked before the call to mq_close(), and this process is the last process to call mq_close() on the queue, then the queue, along with its contents, is destroyed.

Calling close() with a file descriptor that represents a message queue has the same effect as calling mq_close().

Returns:

0 if the message queue is successfully closed, otherwise -1, and errno is set.

Errors:

EBADF
mqdes doesn't represent a valid queue

Classification:

POSIX 1003.4

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

Caveats:

In order to use the mq_... functions, you must:

See also:

close(), errno, mq_getattr(), mq_notify(), mq_open(), mq_receive(), mq_send(), mq_setattr(), mq_unlink()

chapter on POSIX.4 message queues


[Previous]
[Contents]
[Next]