1MQ_OPEN(3)                 Linux Programmer's Manual                MQ_OPEN(3)
2
3
4

NAME

6       mq_open - open a message queue
7

SYNOPSIS

9       #include <mqueue.h>
10
11       mqd_t mq_open(const char *name, int oflag);
12       mqd_t mq_open(const char *name, int oflag, mode_t mode,
13                     struct mq_attr *attr);
14

DESCRIPTION

16       mq_open() creates a new POSIX message queue or opens an existing queue.
17       The queue is identified by name.  For details of  the  construction  of
18       name, see mq_overview(7).
19
20       The  oflag  argument  specifies flags that control the operation of the
21       call.  Exactly one of the following must be specified in oflag:
22
23       O_RDONLY
24              Open the queue to receive messages only.
25
26       O_WRONLY
27              Open the queue to send messages only.
28
29       O_RDWR Open the queue to both send and receive messages.
30
31       Zero or more of the following flags can additionally be ORed in oflag:
32
33       O_NONBLOCK
34              Open the queue in non-blocking  mode.   In  circumstances  where
35              mq_receive() and mq_send() would normally block, these functions
36              instead fail with the error EAGAIN.
37
38       O_CREAT
39              Create the message queue if it does not exist.  The owner  (user
40              ID)  of the message queue is set to the effective user ID of the
41              calling process.  The group ownership (group ID) is set  to  the
42              effective group ID of the calling process.
43
44       O_EXCL If  O_CREAT  was  specified in oflag, and a queue with the given
45              name already exists, then fail with the error EEXIST.
46
47       If O_CREAT is specified in oflag, then two additional arguments must be
48       supplied.   The mode argument specifies the permissions to be placed on
49       the new queue,       as for  open(2).   The  permissions  settings  are
50       masked   against  the  process  umask.   The  attr  argument  specifies
51       attributes for the queue.  See mq_getattr(2) for details.  If  attr  is
52       NULL,  then  the  queue  is created with implementation-defined default
53       attributes.
54

RETURN VALUE

56       On success, mq_open() returns a message queue  descriptor  for  use  by
57       other message queue functions.  On error, mq_open() returns (mqd_t) -1,
58       with errno set to indicate the error.
59

ERRORS

61       EACCES The queue exists, but the caller does  not  have  permission  to
62              open it in the specified mode.
63
64       EINVAL O_CREAT  was  specified  in  oflag,  and  attr was not NULL, but
65              attr->mq_maxmsg or attr->mq_msqsize was invalid.  Both of  these
66              fields must be greater than zero.  In a process that is unprivi‐
67              leged  (does  not   have   the   CAP_SYS_RESOURCE   capability),
68              attr->mq_maxmsg must be less than or equal to the msg_max limit,
69              and attr->mq_msgsize must be less than  or  equal  to  the  msg‐
70              size_max  limit.   In  addition,  even  in a privileged process,
71              attr->mq_maxmsg cannot exceed the HARD_MAX limit.  (See mq_over‐
72              view(7) for details of these limits.)
73
74       EEXIST Both  O_CREAT  and  O_EXCL  were specified in oflag, but a queue
75              with this name already exists.
76
77       EMFILE The process already has the maximum number of files and  message
78              queues open.
79
80       ENAMETOOLONG
81              name was too long.
82
83       ENFILE The  system  limit on the total number of open files and message
84              queues has been reached.
85
86       ENOENT The O_CREAT flag was not specified in oflag, and no  queue  with
87              this name exists.
88
89       ENOMEM Insufficient memory.
90
91       ENOSPC Insufficient  space  for  the  creation  of a new message queue.
92              This probably occurred because the queues_max limit was  encoun‐
93              tered; see mq_overview(7).
94

CONFORMING TO

96       POSIX.1-2001.
97

BUGS

99       In kernels before 2.6.14, the process umask was not applied to the per‐
100       missions specified in mode.
101

SEE ALSO

103       mq_close(3), mq_getattr(3),  mq_notify(3),  mq_receive(3),  mq_send(3),
104       mq_unlink(3), mq_overview(7)
105
106
107
108Linux 2.6.16                      2006-02-25                        MQ_OPEN(3)
Impressum