210 lines
7.4 KiB
HTML
210 lines
7.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>shmget</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="shmget"></a> <a name="tag_03_678"></a><!-- shmget -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_678_01"></a>NAME</h4>
|
|
|
|
<blockquote>shmget - get an XSI shared memory segment</blockquote>
|
|
|
|
<h4><a name="tag_03_678_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/sys/shm.h.html">sys/shm.h</a>><br>
|
|
<br>
|
|
int shmget(key_t</tt> <i>key</i><tt>, size_t</tt> <i>size</i><tt>, int</tt> <i>shmflg</i><tt>); <img src="../images/opt-end.gif"
|
|
alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_678_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>shmget</i>() function operates on XSI shared memory (see the Base Definitions volume of IEEE Std 1003.1-2001,
|
|
<a href="../basedefs/xbd_chap03.html#tag_03_340">Section 3.340, Shared Memory Object</a>). It is unspecified whether this function
|
|
interoperates with the realtime interprocess communication facilities defined in <a href=
|
|
"xsh_chap02_08.html#tag_02_08"><i>Realtime</i></a> .</p>
|
|
|
|
<p>The <i>shmget</i>() function shall return the shared memory identifier associated with <i>key</i>.</p>
|
|
|
|
<p>A shared memory identifier, associated data structure, and shared memory segment of at least <i>size</i> bytes (see <a href=
|
|
"../basedefs/sys/shm.h.html"><i><sys/shm.h></i></a>) are created for <i>key</i> if one of the following is true:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The argument <i>key</i> is equal to IPC_PRIVATE.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The argument <i>key</i> does not already have a shared memory identifier associated with it and (<i>shmflg</i> &IPC_CREAT)
|
|
is non-zero.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>Upon creation, the data structure associated with the new shared memory identifier shall be initialized as follows:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The values of <i>shm_perm.cuid</i>, <i>shm_perm.uid</i>, <i>shm_perm.cgid</i>, and <i>shm_perm.gid</i> are set equal to the
|
|
effective user ID and effective group ID, respectively, of the calling process.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The low-order nine bits of <i>shm_perm.mode</i> are set equal to the low-order nine bits of <i>shmflg</i>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The value of <i>shm_segsz</i> is set equal to the value of <i>size</i>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The values of <i>shm_lpid</i>, <i>shm_nattch</i>, <i>shm_atime</i>, and <i>shm_dtime</i> are set equal to 0.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The value of <i>shm_ctime</i> is set equal to the current time.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>When the shared memory segment is created, it shall be initialized with all zero values.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>shmget</i>() shall return a non-negative integer, namely a shared memory identifier; otherwise,
|
|
it shall return -1 and set <i>errno</i> to indicate the error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>shmget</i>() function shall fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EACCES]</dt>
|
|
|
|
<dd>A shared memory identifier exists for <i>key</i> but operation permission as specified by the low-order nine bits of
|
|
<i>shmflg</i> would not be granted; see <a href="xsh_chap02_07.html#tag_02_07"><i>XSI Interprocess Communication</i></a> .</dd>
|
|
|
|
<dt>[EEXIST]</dt>
|
|
|
|
<dd>A shared memory identifier exists for the argument <i>key</i> but (<i>shmflg</i> &IPC_CREAT) &&(<i>shmflg</i>
|
|
&IPC_EXCL) is non-zero.</dd>
|
|
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>A shared memory segment is to be created and the value of size is less than the system-imposed minimum or greater than the
|
|
system-imposed maximum.</dd>
|
|
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>No shared memory segment is to be created and a shared memory segment exists for <i>key</i> but the size of the segment
|
|
associated with it is less than <i>size</i> and <i>size</i> is not 0.</dd>
|
|
|
|
<dt>[ENOENT]</dt>
|
|
|
|
<dd>A shared memory identifier does not exist for the argument <i>key</i> and (<i>shmflg</i> &IPC_CREAT) is 0.</dd>
|
|
|
|
<dt>[ENOMEM]</dt>
|
|
|
|
<dd>A shared memory identifier and associated shared memory segment shall be created, but the amount of available physical memory
|
|
is not sufficient to fill the request.</dd>
|
|
|
|
<dt>[ENOSPC]</dt>
|
|
|
|
<dd>A shared memory identifier is to be created, but the system-imposed limit on the maximum number of allowed shared memory
|
|
identifiers system-wide would be exceeded.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_678_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>The POSIX Realtime Extension defines alternative interfaces for interprocess communication. Application developers who need to
|
|
use IPC should design their applications so that modules using the IPC routines described in <a href=
|
|
"xsh_chap02_07.html#tag_02_07"><i>XSI Interprocess Communication</i></a> can be easily modified to use the alternative
|
|
interfaces.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="xsh_chap02_07.html#tag_02_07"><i>XSI Interprocess Communication</i></a> , <a href=
|
|
"xsh_chap02_08.html#tag_02_08"><i>Realtime</i></a> , <a href="shmat.html"><i>shmat</i>()</a> , <a href=
|
|
"shmctl.html"><i>shmctl</i>()</a> , <a href="shmdt.html"><i>shmdt</i>()</a> , <a href="shm_open.html"><i>shm_open</i>()</a> , <a
|
|
href="shm_unlink.html"><i>shm_unlink</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/sys/shm.h.html"><i><sys/shm.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2. Derived from Issue 2 of the SVID.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_678_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Moved from SHARED MEMORY to BASE.</p>
|
|
|
|
<p>The note about use of POSIX Realtime Extension IPC routines has been moved from FUTURE DIRECTIONS to a new APPLICATION USAGE
|
|
section.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|