📄 syscalls_82.html
字号:
<!-- This HTML file has been created by texi2html 1.29
from syscalls.texi on 4 June 1994 -->
<TITLE>Syscall specifications of Linux - shmget</TITLE>
<P>Go to the <A HREF="syscalls_81.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_81.html">previous</A>, <A HREF="syscalls_83.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_83.html">next</A> section.<P>
<H2><A NAME="SEC82" HREF="syscalls_toc.html#SEC82" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_toc.html#SEC82">shmget</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int shmget(key_t <VAR>key</VAR>, int <VAR>size</VAR>, int <VAR>shmflg</VAR>);</CODE>
<H3>PARAMETERS</H3>
<P>
<VAR>key</VAR>: [in] the shared memory segment identificator.
<P>
<VAR>size</VAR>: [in] size of the segment.
<P>
<VAR>shmflg</VAR>: [in] flags (see description).
<P>
<H3>DESCRIPTION</H3>
<P>
Gets a shared memory segment identifier. If <VAR>key</VAR> is
<CODE>IPC_PRIVATE</CODE>, a new segment is created. Otherwise, the result
depends on the value of <VAR>shmflg</VAR>:
<P>
<DL COMPACT>
<DT><CODE>IPC_CREAT</CODE>
<DD>creates a new segment for the key if it does not already exist.
<P>
<DT><CODE>IPC_EXCL</CODE>
<DD>if there is already a existing segment associated with <VAR>key</VAR>, the call
fails.
</DL>
<P>
The value of <CODE>size</CODE> is rounded up to a multiple of <CODE>PAGE_SIZE</CODE>.
<P>
The 9 lower bits of <VAR>shmflg</VAR> specify the permission bits of the new
segment. They have the same layout and meaning as those for files.
However, the execute permissions are meaningless for segments.
<P>
When creating a segment the system sets the appropriate parameters in
the <CODE>shmid_ds</CODE> structure associated with the new segment. When
accessing an already existing segment, the system simply check if the
segment can be accessed.
<P>
<H3>RETURN VALUE</H3>
<P>
On success, the call returns the new shared memory segment
identificator. On error -1 is returned and <CODE>errno</CODE> is set to one of
the following values:
<P>
<UL>
<LI><CODE>EACCESS</CODE>: the task has no access permission to the segment.
<LI><CODE>EEXIST</CODE>: <CODE>IPC_CREAT</CODE> and <CODE>IPC_EXCL</CODE> were specified
and the segment already exists.
<LI><CODE>EIDRM</CODE>: the segment no longer exists in the system.
<LI><CODE>ENOENT</CODE>: the segment never existed.
<LI><CODE>ENOSPC</CODE>: the maximum number of shared memory segment for the
system has been reached.
<LI><CODE>EINVAL</CODE>: <VAR>size</VAR> is outside the range [SHMMIN,SHMMAX] or
is greater than the size of the segment (in the case where it already exists).
<LI><CODE>ENOMEM</CODE>
</UL>
<P>
<P>Go to the <A HREF="syscalls_81.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_81.html">previous</A>, <A HREF="syscalls_83.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_83.html">next</A> section.<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -