OSDN Git Service

Update drafts for LDP 3.67
[linuxjm/LDP_man-pages.git] / draft / man2 / shmget.2
1 .\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified Wed Jul 28 10:57:35 1993, Rik Faith <faith@cs.unc.edu>
26 .\" Modified Sun Nov 28 16:43:30 1993, Rik Faith <faith@cs.unc.edu>
27 .\"          with material from Giorgio Ciucci <giorgio@crcc.it>
28 .\" Portions Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
29 .\" Modified Tue Oct 22 22:03:17 1996 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
31 .\"     Removed EIDRM from errors - that can't happen...
32 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\"     Added notes on capability requirements
34 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
35 .\"     Language and formatting clean-ups
36 .\"     Added notes on /proc files
37 .\"
38 .\"*******************************************************************
39 .\"
40 .\" This file was generated with po4a. Translate the source file.
41 .\"
42 .\"*******************************************************************
43 .\"
44 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
45 .\"         all rights reserved.
46 .\" Translated 1997-03-01, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
47 .\" Updated & Modified 2001-06-03, Yuichi SATO <ysato@h4.dion.ne.jp>
48 .\" Updated 2001-12-22, Kentaro Shirakata <argrath@ub32.org>
49 .\" Updated 2002-10-16, Kentaro Shirakata <argrath@ub32.org>
50 .\" Updated 2003-02-23, Kentaro Shirakata <argrath@ub32.org>
51 .\" Updated 2005-03-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
52 .\" Updated 2005-11-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
53 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
54 .\" Updated 2013-05-06, Akihiro MOTOKI <amotoki@gmail.com>
55 .\" Updated 2013-07-24, Akihiro MOTOKI <amotoki@gmail.com>
56 .\"
57 .TH SHMGET 2 2014\-05\-21 Linux "Linux Programmer's Manual"
58 .SH 名前
59 shmget \- System V 共有メモリ・セグメントを割り当てる
60 .SH 書式
61 .ad l
62 \fB#include <sys/ipc.h>\fP
63 .br
64 \fB#include <sys/shm.h>\fP
65 .sp
66 \fBint shmget(key_t \fP\fIkey\fP\fB, size_t \fP\fIsize\fP\fB, int \fP\fIshmflg\fP\fB);\fP
67 .ad b
68 .SH 説明
69 \fBshmget\fP()  は \fIkey\fP 引き数に対応する System\ V 共有メモリ・セグメントの識別子を返す。 \fIkey\fP の値が
70 \fBIPC_PRIVATE\fP の場合、もしくは \fIkey\fP に対応する共有メモリ・セグメントが存在せず、 \fIshmflg\fP に
71 \fBIPC_CREAT\fP が指定されていた場合、 新しい共有メモリ・セグメントを作成する。 作成される共有メモリ・セグメントは、 \fIsize\fP
72 引き数の値を \fBPAGE_SIZE\fP の倍数へと切り上げた (round up) 大きさとなる。
73 .PP
74 \fIshmflg\fP に \fBIPC_CREAT\fP と \fBIPC_EXCL\fP の両方が指定された場合、 \fIkey\fP
75 に対応する共有メモリ・セグメントが既に存在すると、 \fBshmget\fP()  は失敗し、 \fIerrno\fP に \fBEEXIST\fP が設定される
76 (これは \fBopen\fP(2)  に \fBO_CREAT | O_EXCL\fP を指定した場合の動作と同じである)。
77 .PP
78 \fIshmflg\fP は以下の内容から構成される:
79 .TP  12
80 \fBIPC_CREAT\fP
81 新しいセグメントを作成する。このフラグが指定されなかった場合、 \fBshmget\fP()  は \fIkey\fP に対応するセグメントを探し、
82 ユーザがそのセグメントにアクセスする許可があるかどうかをチェックする。
83 .TP 
84 \fBIPC_EXCL\fP
85 This flag is used with \fBIPC_CREAT\fP to ensure that this call creates the
86 segment.  If the segment already exists, the call fails.
87 .TP 
88 \fBSHM_HUGETLB\fP (Linux 2.6 以降)
89 "ヒュージページ (huge page)" を使うセグメントを割り当てる。詳細な情報は、Linux カーネルソースのファイル
90 \fIDocumentation/vm/hugetlbpage.txt\fP を参照。
91 .TP 
92 \fBSHM_NORESERVE\fP (Linux 2.6.15 以降)
93 .\" As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
94 .\" specified.
95 このフラグは、 \fBmmap\fP(2)  の \fBMAP_NORESERVE\fP フラグと同じ役割を果たす。
96 このセグメントに対するスワップ空間の予約を行わない。 スワップ空間を予約した場合は、そのセグメントの変更が必ず成功することが
97 保証される。スワップ空間の予約を行わなかった場合は、物理メモリに空きが ないと書き込み時に \fBSIGSEGV\fP を受け取る可能性がある。
98 \fBproc\fP(5)  にある \fI/proc/sys/vm/overcommit_memory\fP ファイルに関する議論も参照のこと。
99 .PP
100 In addition to the above flags, the least significant 9 bits of \fIshmflg\fP
101 specify the permissions granted to the owner, group, and others.  These bits
102 have the same format, and the same meaning, as the \fImode\fP argument of
103 \fBopen\fP(2).  Presently, execute permissions are not used by the system.
104 .PP
105 共有メモリ・セグメントが新たに作成される際、 共有メモリ・セグメントの内容は 0 で初期化され、 関連情報を保持するデータ構造体 \fIshmid_ds\fP
106 は以下のように初期化される。
107 .IP
108 \fIshm_perm.cuid\fP と \fIshm_perm.uid\fP に呼び出し元プロセスの実効 (effective) ユーザーID を設定する。
109 .IP
110 \fIshm_perm.cgid\fP と \fIshm_perm.gid\fP に呼び出し元プロセスの実効グループID を設定する。
111 .IP
112 \fIshm_perm.mode\fP の下位 9 ビットに \fIshmflg\fP の下位 9 ビットを設定する。
113 .IP
114 \fIshm_segsz\fP に \fIsize\fP の値を設定する。
115 .IP
116 \fIshm_lpid\fP, \fIshm_nattch\fP, \fIshm_atime\fP, \fIshm_dtime\fP に 0 を設定する。
117 .IP
118 \fIshm_ctime\fP に現在の時刻を設定する。
119 .PP
120 共有メモリ・セグメントが既に存在する場合、アクセス許可の検査と、 破壊 (destruction) マークがつけられていないかのチェックが行われる。
121 .SH 返り値
122 成功の場合、有効な共有メモリ・セグメントの識別子が返される。 エラーの場合、 \-1 が返り、 \fIerror\fP にエラーを示す値が設定される。
123 .SH エラー
124 失敗した場合は \fIerrno\fP が以下のどれかに設定される:
125 .TP 
126 \fBEACCES\fP
127 ユーザーはその共有メモリ・セグメントへのアクセス許可を持たず、 \fBCAP_IPC_OWNER\fP ケーパビリティも持っていない。
128 .TP 
129 \fBEEXIST\fP
130 \fBIPC_CREAT\fP and \fBIPC_EXCL\fP were specified in \fIshmflg\fP, but a shared
131 memory segment already exists for \fIkey\fP.
132 .TP 
133 \fBEINVAL\fP
134 A new segment was to be created and \fIsize\fP is less than \fBSHMIN\fP or greater
135 than \fBSHMMAX\fP.
136 .TP 
137 \fBEINVAL\fP
138 (The call did not create a new segment and)  a segment for the given \fIkey\fP
139 exists, but \fIsize\fP is greater than the size of that segment.
140 .TP 
141 \fBENFILE\fP
142 .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
143 システム全体でオープンされているファイルの総数が上限に達した。
144 .TP 
145 \fBENOENT\fP
146 指定された \fIkey\fP に対応するセグメントが存在せず、 \fBIPC_CREAT\fP も指定されていなかった。
147 .TP 
148 \fBENOMEM\fP
149 セグメントの管理情報 (overhead) に割り当てるメモリがなかった。
150 .TP 
151 \fBENOSPC\fP
152 システム全体の共有メモリ・セグメント数の制限 (\fBSHMMNI\fP)  に達した、または要求された \fIsize\fP のセグメントの割り当てが
153 システム全体の共有メモリサイズの制限 (\fBSHMALL\fP)  を超過した。
154 .TP 
155 \fBEPERM\fP
156 \fBSHM_HUGETLB\fP フラグが指定されたが、呼び出し元には権限がなかった (\fBCAP_IPC_LOCK\fP ケーパビリティを持っていなかった)。
157 .SH 準拠
158 .\" SVr4 documents an additional error condition EEXIST.
159 SVr4, POSIX.1\-2001.
160
161 \fBSHM_HUGETLB\fP と \fBSHM_NORESERVE\fP は Linux での拡張である。
162 .SH 注意
163 .\" Like Linux, the FreeBSD man pages still document
164 .\" the inclusion of these header files.
165 Linux や POSIX の全てのバージョンでは、 \fI<sys/types.h>\fP と \fI<sys/ipc.h>\fP
166 のインクルードは必要ない。しかしながら、いくつかの古い実装ではこれらのヘッダファイルのインクルードが必要であり、 SVID
167 でもこれらのインクルードをするように記載されている。このような古いシステムへの移植性を意図したアプリケーションではこれらのファイルをインクルードする必要があるかもしれない。
168
169 .\"
170 \fBIPC_PRIVATE\fP はフラグではなく \fIkey_t\fP 型である。 この特別な値が \fIkey\fP に使用された場合は、 \fBshmget\fP()
171 は \fIshmflg\fP の下位 9 ビットを除いた全てを無視し、 新しい共有メモリ・セグメントを作成する。
172 .SS "Shared memory limits"
173 \fBshmget\fP()  コールに影響する共有メモリ・セグメント資源の制限は以下の通りである:
174 .TP 
175 \fBSHMALL\fP
176 システム全体の共有メモリ・ページ数の上限値。 Linux 2.2 以降では、この上限値のデフォルトは以下である。
177
178     SHMMAX / PAGE_SIZE * (SHMMNI / 16)
179
180 If \fBSHMMAX\fP and \fBSHMMNI\fP are not modified, this yields a limit for the
181 total memory used by all shared memory segments of 8 GB: With a 4kB page
182 size, this formula yields the value 2^21 (2,097,152), with 8kB page size, it
183 yields 2^20 (1048576).
184
185 Linux では、この上限値は \fI/proc/sys/kernel/shmall\fP 経由で参照したり、変更したりできる。
186 .TP 
187 \fBSHMMAX\fP
188 共有メモリ・セグメントの最大バイト数。 Linux 2.2 以降では、 この上限値のデフォルトは 0x2000000 (32MB) である。
189
190 Linux では、この上限値は \fI/proc/sys/kernel/shmmax\fP 経由で参照したり、変更したりできる。
191 .TP 
192 \fBSHMMIN\fP
193 共有メモリ・セグメントのバイト単位の大きさの下限: 実装依存 (現在は 1 バイトだが、実質的な最小サイズは \fBPAGE_SIZE\fP である)。
194 .TP 
195 \fBSHMMNI\fP
196 システム全体の共有メモリ・セグメント数の上限値。 この上限値のデフォルトは、 Linux 2.2 以降では 128、 Linux 2.4 以降で
197 4096 である。
198
199 .\" Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
200 .\" that we could create one more segment than SHMMNI -- MTK
201 .\" This /proc file is not available in Linux 2.2 and earlier -- MTK
202 Linux では、この上限値は \fI/proc/sys/kernel/shmmni\fP 経由で参照したり、変更したりできる。
203 .PP
204 プロセス当りの共有メモリ・セグメントの個数の最大値 (\fBSHMSEG\fP)  に関する実装上の制限はない。
205 .SS "Linux での注意"
206 バージョン 2.3.30 までは、Linux は 削除が予定されている共有メモリ・セグメントに対して \fBshmget\fP()  が行われると
207 \fBEIDRM\fP を返していた。
208 .SH バグ
209 \fBIPC_PRIVATE\fP という名前を選んだのはおそらく失敗であろう。 \fBIPC_NEW\fP の方がより明確にその機能を表しているだろう。
210 .SH 関連項目
211 \fBshmat\fP(2), \fBshmctl\fP(2), \fBshmdt\fP(2), \fBftok\fP(3), \fBcapabilities\fP(7),
212 \fBshm_overview\fP(7), \fBsvipc\fP(7)
213 .SH この文書について
214 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
215 である。プロジェクトの説明とバグ報告に関する情報は
216 http://www.kernel.org/doc/man\-pages/ に書かれている。