{"id":5550,"date":"2022-12-20T18:45:26","date_gmt":"2022-12-20T21:45:26","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mq_open-man3p\/"},"modified":"2022-12-20T18:45:26","modified_gmt":"2022-12-20T21:45:26","slug":"mq_open-man3p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mq_open-man3p\/","title":{"rendered":"MQ_OPEN (man3p)"},"content":{"rendered":"<h1 align=\"center\">MQ_OPEN<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">mq_open \u2014 open a message queue (<b>REALTIME<\/b>)<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">#include <mqueue.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">mqd_t mq_open(const char *<i>name<\/i>, int <i>oflag<\/i>, &#8230;);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mq_open<\/i>() function shall establish the connection between a process and a message queue with a message queue descriptor. It shall create an open message queue description that refers to the message queue, and a message queue descriptor that refers to that open message queue description. The message queue descriptor is used by other functions to refer to that message queue. The <i>name<\/i> argument points to a string naming a message queue. It is unspecified whether the name appears in the file system and is visible to other functions that take pathnames as arguments. The <i>name<\/i> argument conforms to the construction rules for a pathname, except that the interpretation of <slash> characters other than the leading <slash> character in <i>name<\/i> is implementation-defined, and that the length limits for the <i>name<\/i> argument are implementation-defined and need not be the same as the pathname limits {PATH_MAX} and {NAME_MAX}. If <i>name<\/i> begins with the <slash> character, then processes calling <i>mq_open<\/i>() with the same value of <i>name<\/i> shall refer to the same message queue object, as long as that name has not been removed. If <i>name<\/i> does not begin with the <slash> character, the effect is implementation-defined. If the <i>name<\/i> argument is not the name of an existing message queue and creation is not requested, <i>mq_open<\/i>() shall fail and return an error.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A message queue descriptor may be implemented using a file descriptor, in which case applications can open up to at least {OPEN_MAX} file and message queues.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>oflag<\/i> argument requests the desired receive and\/or send access to the message queue. The requested access permission to receive messages or send messages shall be granted if the calling process would be granted read or write access, respectively, to an equivalently protected file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The value of <i>oflag<\/i> is the bitwise-inclusive OR of values from the following list. Applications shall specify exactly one of the first three values (access modes) below in the value of <i>oflag<\/i>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p>O_RDONLY<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"71%\">\n<p>Open the message queue for receiving messages. The process can use the returned message queue descriptor with <i>mq_receive<\/i>(), but not <i>mq_send<\/i>(). A message queue may be open multiple times in the same or different processes for receiving messages.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p>O_WRONLY<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"71%\">\n<p>Open the queue for sending messages. The process can use the returned message queue descriptor with <i>mq_send<\/i>() but not <i>mq_receive<\/i>(). A message queue may be open multiple times in the same or different processes for sending messages.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p>O_RDWR<\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"71%\">\n<p>Open the queue for both receiving and sending messages. The process can use any of the functions allowed for O_RDONLY and O_WRONLY. A message queue may be open multiple times in the same or different processes for sending messages.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">Any combination of the remaining flags may be specified in the value of <i>oflag<\/i>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p style=\"margin-top: 1em\">O_CREAT<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"71%\">\n<p style=\"margin-top: 1em\">Create a message queue. It requires two additional arguments: <i>mode<\/i>, which shall be of type <b>mode_t<\/b>, and <i>attr<\/i>, which shall be a pointer to an <b>mq_attr<\/b> structure. If the pathname <i>name<\/i> has already been used to create a message queue that still exists, then this flag shall have no effect, except as noted under O_EXCL. Otherwise, a message queue shall be created without any messages in it. The user ID of the message queue shall be set to the effective user ID of the process. The group ID of the message queue shall be set to the effective group ID of the process; however, if the <i>name<\/i> argument is visible in the file system, the group ID may be set to the group ID of the containing directory. When bits in <i>mode<\/i> other than the file permission bits are specified, the effect is unspecified. If <i>attr<\/i> is NULL, the message queue shall be created with implementation-defined default message queue attributes. If <i>attr<\/i> is non-NULL and the calling process has appropriate privileges on <i>name<\/i>, the message queue <i>mq_maxmsg<\/i> and <i>mq_msgsize<\/i> attributes shall be set to the values of the corresponding members in the <b>mq_attr<\/b> structure referred to by <i>attr<\/i>. The values of the <i>mq_flags<\/i> and <i>mq_curmsgs<\/i> members of the <b>mq_attr<\/b> structure shall be ignored. If <i>attr<\/i> is non-NULL, but the calling process does not have appropriate privileges on <i>name<\/i>, the <i>mq_open<\/i>() function shall fail and return an error without creating the message queue.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p>O_EXCL<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"71%\">\n<p>If O_EXCL and O_CREAT are set, <i>mq_open<\/i>() shall fail if the message queue <i>name<\/i> exists. The check for the existence of the message queue and the creation of the message queue if it does not exist shall be atomic with respect to other threads executing <i>mq_open<\/i>() naming the same <i>name<\/i> with O_EXCL and O_CREAT set. If O_EXCL is set and O_CREAT is not set, the result is undefined.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"15%\">\n<p>O_NONBLOCK<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"71%\">\n<p>Determines whether an <i>mq_send<\/i>() or <i>mq_receive<\/i>() waits for resources or messages that are not currently available, or fails with <i>errno<\/i> set to <b>[EAGAIN]<\/b>; see <i>mq_send<\/i>() and <i>mq_receive<\/i>() for details.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mq_open<\/i>() function does not add or remove messages from the queue.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Upon successful completion, the function shall return a message queue descriptor; otherwise, the function shall return (<b>mqd_t<\/b>)\u22121 and set <i>errno<\/i> to indicate the error.<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>mq_open<\/i>() function shall fail if:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><b>EACCES<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">The message queue exists and the permissions specified by <i>oflag<\/i> are denied, or the message queue does not exist and permission to create the message queue is denied.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EEXIST<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>O_CREAT and O_EXCL are set and the named message queue already exists.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EINTR<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>The <i>mq_open<\/i>() function was interrupted by a signal.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EINVAL<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>The <i>mq_open<\/i>() function is not supported for the given name.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EINVAL<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>O_CREAT was specified in <i>oflag<\/i>, the value of <i>attr<\/i> is not NULL, and either <i>mq_maxmsg<\/i> or <i>mq_msgsize<\/i> was less than or equal to zero.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EMFILE<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>Too many message queue descriptors or file descriptors are currently in use by this process.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ENFILE<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>Too many message queues are currently open in the system.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ENOENT<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>O_CREAT is not set and the named message queue does not exist.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ENOSPC<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>There is insufficient space for the creation of the new message queue.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">If any of the following conditions occur, the <i>mq_open<\/i>() function may return (<b>mqd_t<\/b>)\u22121 and set <i>errno<\/i> to the corresponding value. <b><br \/> ENAMETOOLONG<\/b><\/p>\n<p style=\"margin-left:22%;\">The length of the <i>name<\/i> argument exceeds {_POSIX_PATH_MAX} on systems that do not support the XSI option or exceeds {_XOPEN_PATH_MAX} on XSI systems, or has a pathname component that is longer than {_POSIX_NAME_MAX} on systems that do not support the XSI option or longer than {_XOPEN_NAME_MAX} on XSI systems.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">A future version might require the <i>mq_open<\/i>() and <i>mq_unlink<\/i>() functions to have semantics similar to normal file system operations.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>mq_close<\/i>(), <i>mq_getattr<\/i>(), <i>mq_receive<\/i>(), <i>mq_send<\/i>(), <i>mq_setattr<\/i>(), <i>mq_unlink<\/i>(), <i>msgctl<\/i>(), <i>msgget<\/i>(), <i>msgrcv<\/i>(), <i>msgsnd<\/i>()<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <b><mqueue.h><\/b><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  mq_open \u2014 open a message queue (REALTIME) <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3779,1],"tags":[1594,2436],"class_list":["post-5550","post","type-post","status-publish","format-standard","hentry","category-3pm-perl-llamadas-de-bibliotecas","category-sin-categoria","tag-man3p","tag-mq_open"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=5550"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5550\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}