⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shmget.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>shmget</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_008_570">&nbsp;</a>NAME</h4><blockquote>shmget - get shared memory segment</blockquote><h4><a name = "tag_000_008_571">&nbsp;</a>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="sysshm.h.html">sys/shm.h</a>&gt;int shmget(key_t <i>key</i>, size_t <i>size</i>, int <i>shmflg</i>);</code></pre></blockquote><h4><a name = "tag_000_008_572">&nbsp;</a>DESCRIPTION</h4><blockquote>The<i>shmget()</i>function returns the shared memory identifier associated with<i>key</i>.<p>A shared memory identifier, associated data structureand shared memory segment of at least<i>size</i>bytes, see<i><a href="sysshm.h.html">&lt;sys/shm.h&gt;</a></i>,are created for<i>key</i>if one of the following is true:<ul><p><li>The argument<i>key</i>is equal to IPC_PRIVATE.<p><li>The argument<i>key</i>does not already have a shared memory identifierassociated with it and (<i>shmflg</i>&amp;IPC_CREAT) is non-zero.<p></ul><p>Upon creation, the data structure associated withthe new shared memory identifier is initialised as follows:<ul><p><li>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 andeffective group ID, respectively, of the calling process.<p><li>The low-order nine bits of<i>shm_perm.mode</i>are set equal to the low-order nine bits of<i>shmflg</i>.The value of<i>shm_segsz</i>is set equal to the value of<i>size</i>.<p><li>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>The value of<i>shm_ctime</i>is set equal to the current time.<p></ul><p>When the shared memory segment is created, it will be initialised withall zero values.</blockquote><h4><a name = "tag_000_008_573">&nbsp;</a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>shmget()</i>returns a non-negative integer,namely a shared memory identifier;otherwise, it returns -1 and<i>errno</i>will be set to indicate the error.</blockquote><h4><a name = "tag_000_008_574">&nbsp;</a>ERRORS</h4><blockquote>The<i>shmget()</i>function will fail if:<dl compact><dt>[EACCES]<dd>A shared memory identifier exists for<i>key</i>but operation permission as specifiedby the low-order nine bits of<i>shmflg</i>would not be granted.See<a href="ipc.html">IPC</a>.<dt>[EEXIST]<dd>A shared memory identifier exists for the argument<i>key</i>but (<i>shmflg</i>&amp;IPC_CREAT)&amp;&amp;(<i>shmflg</i>&amp;IPC_EXCL)is non-zero.<dt>[EINVAL]<dd>The value of<i>size</i>is less than the system-imposed minimum orgreater than the system-imposed maximum,or a shared memory identifier exists for the argument<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.<dt>[ENOENT]<dd>A shared memory identifier does not exist for the argument<i>key</i>and (<i>shmflg</i>&amp;IPC_CREAT) is 0.<dt>[ENOMEM]<dd>A shared memory identifier and associated shared memory segment are to becreated but the amount of available physical memory is not sufficient tofill the request.<dt>[ENOSPC]<dd>A shared memory identifier is to be created butthe system-imposed limit on the maximum number ofallowed shared memory identifiers system-wide would be exceeded.</dl></blockquote><h4><a name = "tag_000_008_575">&nbsp;</a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_008_576">&nbsp;</a>APPLICATION USAGE</h4><blockquote>The POSIX Realtime Extension defines alternative interfaces for interprocess communication.Application developers who need to use IPC should design theirapplications so that modules using the IPC routines described in<a href="ipc.html">IPC</a>can be easily modified to use the alternative interfaces.</blockquote><h4><a name = "tag_000_008_577">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_008_578">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="shmat.html">shmat()</a></i>,<i><a href="shmctl.html">shmctl()</a></i>,<i><a href="shmdt.html">shmdt()</a></i>,<i><a href="shm_open.html">shm_open()</a></i>,<i><a href="shm_unlink.html">shm_unlink()</a></i>,<i><a href="sysshm.h.html">&lt;sys/shm.h&gt;</a></i>,<a href="ipc.html">IPC</a>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 2 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -