<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
-->
</style></head>
<body style="margin:0px 0px 0px 0px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">MSGGET</span></td>
</tr>
<tr>
<td><p style="margin-left:22px;margin-top:0px"><br />
Return the message queue identifier associated with the value of the <em>ecx</em> argument.</p>
<p style="margin-left:10px"><strong>Arguments</strong></p>
<table width="100%" border="0" style="margin-left:20px; margin-right:20px">
<tr>
<td width="6%" valign="top"><em>ecx</em></td>
<td width="94%">Key value. This key value is compared to existing key values that exist within the kernel for other message queues.<br />
If IPC_PRIVATE is specified for this argument, a new message queue will be created and the system call will ignore everything but the least significant 9 bits of <em>edx</em>.</td>
</tr>
<tr>
<td valign="top"><em>edx</em></td>
<td>Operation flags:<br />
<table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="11%" valign="top"><code>IPC_CREAT </code></td>
<td width="89%"><code>Create the queue if it doesn't already exist in the kernel and argument in <em>ecx</em> is not IPC_PRIVATE.</code></td>
</tr>
<tr>
<td valign="top"><code>IPC_EXCL </code></td>
<td><code>When used with IPC_CREAT, fail if queue already exists. </code></td>
</tr>
</table></td>
</tr>
</table>
<br />
If both IPC_CREAT and IPC_EXCL are specified and a message queue already exists for <em>ecx</em>, then MSGGET fails with <em>-</em>EEXIST. (This is analogous to the effect of the combination "O_CREAT or O_EXCL" for <a href="5.html">sys_open</a>.)<br />
<br />
Upon creation, the least significant bits of the argument <em>edx</em> define the permissions of the message queue:
<table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333">
<tr>
<td><code> S_IRUSR - owner has read permission <br />
S_IWUSR - owner has write permission
<br />
S_IRGRP - group has read permission <br />
S_IWGRP - group has write permission <br />
S_IROTH - others have read permission <br />
S_IWOTH - others have write permission
</code></td>
</tr>
</table>
<br />
If a new message queue is created, then its associated data structure <em>msqid_ds</em> (see <a href="ipc_msgctl.html">MSGCTL</a>) is initialised as follows: <br />
<br />
<em>msg_perm.cuid</em> and <em>msg_perm.uid</em> are set to the effective user ID of the calling process. <br />
<em>msg_perm.cgid</em> and <em>msg_perm.gid</em> are set to the effective group ID of the calling process. <br />
The least significant 9 bits of <em>msg_perm.mode</em> are set to the least significant 9 bits of <em>msgflg</em>. <br />
<em>msg_qnum</em>, <em>msg_lspid</em>, <em>msg_lrpid</em>, <em>msg_stime</em> and <em>msg_rtime</em> are set to 0. <br />
<em>msg_ctime</em> is set to the current time. <br />
<em>msg_qbytes</em> is set to the system limit MSGMNB.<br />
<br />
If the message queue already exists the permissions are verified, and a check is made to see if it is marked for destruction.
</td>
</tr>
</table>
<p style="margin-left:10px" ><strong>Return values</strong></p>
<p style="margin-left:22px;margin-right:10px" >If the function succeeds the return value is a message queue identifier (a nonnegative integer).<br />
If the function fails the return value is one of the following <em>errno</em> values:</p>
<table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333;margin-left:22px;margin-right:22px">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="10%" valign="top"><code>-EACCES </code></td>
<td width="90%"><code>A message queue exists for <em>ecx</em>, but the calling process does not have permission to access the queue, and does not have the CAP_IPC_OWNER capability. </code></td>
</tr>
<tr>
<td valign="top"><code>-EEXIST </code></td>
<td><code>A message queue exists for <em>ecx</em> and <em>edx</em> specified both IPC_CREAT and IPC_EXCL.</code></td>
</tr>
<tr>
<td valign="top"><code>-ENOENT </code></td>
<td><code>No message queue exists for <em>ecx</em> and <em>edx</em> did not specify IPC_CREAT. </code></td>
</tr>
<tr>
<td valign="top"><code>-ENOMEM </code></td>
<td><code> message queue has to be created but the system does not have enough memory for the new data structure. </code></td>
</tr>
<tr>
<td valign="top"><code>-ENOSPC </code></td>
<td><code>A message queue has to be created but the system limit for the maximum number of message queues (MSGMNI) would be exceeded.</code></td>
</tr>
</table></td>
</tr>
</table>
<p style="margin-left:10px"><strong>Remarks</strong></p>
<p style="margin-left:22px">The following is a system limit on message queue resources affecting a MSGGET call: <br />
<br />
MSGMNI - System wide maximum number of message queues: policy dependent (this limit can be read and modified via <em>/proc/sys/kernel/msgmni</em>). </p>
<p style="margin-left:22px">See /samples/ipc/msg.asm for an example. </p></td>
</tr>
</table>
</body></html>