OSDN Git Service

typo fix: error -> errno
[linuxjm/LDP_man-pages.git] / release / 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\-10\-02 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 このフラグは \fBIPC_CREAT\fP とともに使用し、 この呼び出しで確実にセグメントが作成されるようにする。 セグメントが既に存在した場合には、
86 呼び出しは失敗する。
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 上記のフラグに加えて、 \fIshmflg\fP の下位 9 ビットは、所有者、グループ、その他への許可を指定する。 これらのビットは \fBopen\fP(2)
101 の \fImode\fP 引き数と同じ形式で同じ意味を持つ。 今のところ、システムは実行 (execute) 許可を参照しない。
102 .PP
103 共有メモリ・セグメントが新たに作成される際、 共有メモリ・セグメントの内容は 0 で初期化され、 関連情報を保持するデータ構造体 \fIshmid_ds\fP
104 は以下のように初期化される。
105 .IP
106 \fIshm_perm.cuid\fP と \fIshm_perm.uid\fP に呼び出し元プロセスの実効 (effective) ユーザーID を設定する。
107 .IP
108 \fIshm_perm.cgid\fP と \fIshm_perm.gid\fP に呼び出し元プロセスの実効グループID を設定する。
109 .IP
110 \fIshm_perm.mode\fP の下位 9 ビットに \fIshmflg\fP の下位 9 ビットを設定する。
111 .IP
112 \fIshm_segsz\fP に \fIsize\fP の値を設定する。
113 .IP
114 \fIshm_lpid\fP, \fIshm_nattch\fP, \fIshm_atime\fP, \fIshm_dtime\fP に 0 を設定する。
115 .IP
116 \fIshm_ctime\fP に現在の時刻を設定する。
117 .PP
118 共有メモリ・セグメントが既に存在する場合、アクセス許可の検査と、 破壊 (destruction) マークがつけられていないかのチェックが行われる。
119 .SH 返り値
120 成功の場合、有効な共有メモリ・セグメントの識別子が返される。 エラーの場合、 \-1 が返り、 \fIerrno\fP にエラーを示す値が設定される。
121 .SH エラー
122 失敗した場合は \fIerrno\fP が以下のどれかに設定される:
123 .TP 
124 \fBEACCES\fP
125 ユーザーはその共有メモリ・セグメントへのアクセス許可を持たず、 \fBCAP_IPC_OWNER\fP ケーパビリティも持っていない。
126 .TP 
127 \fBEEXIST\fP
128 \fBIPC_CREAT\fP と \fBIPC_EXCL\fP が \fIshmflg\fP に指定されたが、 \fIkey\fP
129 に対応する共有メモリセグメントはすでに存在する。
130 .TP 
131 \fBEINVAL\fP
132 新しいセグメントを作成しようとしたが、 \fIsize\fP が \fBSHMMIN\fP より小さいか \fBSHMMAX\fP よりも大きかった。
133 .TP 
134 \fBEINVAL\fP
135 指定された \fIkey\fP に対応するセグメントが既に存在するが、 \fIsize\fP がそのセグメントのサイズよりも大きかった。
136 .TP 
137 \fBENFILE\fP
138 .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
139 システム全体でオープンされているファイルの総数が上限に達した。
140 .TP 
141 \fBENOENT\fP
142 指定された \fIkey\fP に対応するセグメントが存在せず、 \fBIPC_CREAT\fP も指定されていなかった。
143 .TP 
144 \fBENOMEM\fP
145 セグメントの管理情報 (overhead) に割り当てるメモリがなかった。
146 .TP 
147 \fBENOSPC\fP
148 システム全体の共有メモリ・セグメント数の制限 (\fBSHMMNI\fP)  に達した、または要求された \fIsize\fP のセグメントの割り当てが
149 システム全体の共有メモリサイズの制限 (\fBSHMALL\fP)  を超過した。
150 .TP 
151 \fBEPERM\fP
152 \fBSHM_HUGETLB\fP フラグが指定されたが、呼び出し元には権限がなかった (\fBCAP_IPC_LOCK\fP ケーパビリティを持っていなかった)。
153 .SH 準拠
154 .\" SVr4 documents an additional error condition EEXIST.
155 SVr4, POSIX.1\-2001.
156
157 \fBSHM_HUGETLB\fP と \fBSHM_NORESERVE\fP は Linux での拡張である。
158 .SH 注意
159 .\" Like Linux, the FreeBSD man pages still document
160 .\" the inclusion of these header files.
161 Linux や POSIX の全てのバージョンでは、 \fI<sys/types.h>\fP と \fI<sys/ipc.h>\fP
162 のインクルードは必要ない。しかしながら、いくつかの古い実装ではこれらのヘッダファイルのインクルードが必要であり、 SVID
163 でもこれらのインクルードをするように記載されている。このような古いシステムへの移植性を意図したアプリケーションではこれらのファイルをインクルードする必要があるかもしれない。
164
165 .\"
166 \fBIPC_PRIVATE\fP はフラグではなく \fIkey_t\fP 型である。 この特別な値が \fIkey\fP に使用された場合は、 \fBshmget\fP()
167 は \fIshmflg\fP の下位 9 ビットを除いた全てを無視し、 新しい共有メモリ・セグメントを作成する。
168 .SS "Shared memory limits"
169 \fBshmget\fP()  コールに影響する共有メモリ・セグメント資源の制限は以下の通りである:
170 .TP 
171 \fBSHMALL\fP
172 共有メモリのページ数のシステム全体での上限値。
173
174 .\" commit 060028bac94bf60a65415d1d55a359c3a17d5c31
175 Linux では、この上限値は \fI/proc/sys/kernel/shmall\fP 経由で参照したり、変更したりできる。 Linux 3.16
176 以降では、 この上限値のデフォルト値は以下のとおりである。
177
178     ULONG_MAX \- 2^24
179
180 The effect of this value (which is suitable for both 32\-bit and 64\-bit
181 systems)  is to impose no limitation on allocations.  This value, rather
182 than \fBULONG_MAX\fP, was chosen as the default to prevent some cases where
183 historical applications simply raised the existing limit without first
184 checking its current value.  Such applications would cause the value to
185 overflow if the limit was set at \fBULONG_MAX\fP.
186
187 From Linux 2.4 up to Linux 3.15, the default value for this limit was:
188
189     SHMMAX / PAGE_SIZE * (SHMMNI / 16)
190
191 If \fBSHMMAX\fP and \fBSHMMNI\fP were not modified, then multiplying the result of
192 this formula by the page size (to get a value in bytes) yielded a value of 8
193 GB as the limit on the total memory used by all shared memory segments.
194 .TP 
195 \fBSHMMAX\fP
196 1 つの共有メモリセグメントの最大サイズ (バイト数)。
197
198 .\" commit 060028bac94bf60a65415d1d55a359c3a17d5c31
199 Linux では、この上限値は \fI/proc/sys/kernel/shmmax\fP 経由で参照したり、変更したりできる。 Linux 3.16
200 以降では、 この上限値のデフォルト値は以下のとおりである。
201
202     ULONG_MAX \- 2^24
203
204 The effect of this value (which is suitable for both 32\-bit and 64\-bit
205 systems)  is to impose no limitation on allocations.  See the description of
206 \fBSHMALL\fP for a discussion of why this default value (rather than
207 \fBULONG_MAX\fP)  is used.
208
209 Linux 2.2 から Linux 3.15 までは、この上限値のデフォルト値は 0x2000000 (32MB) であった。
210
211 Because it is not possible to map just part of a shared memory segment, the
212 amount of virtual memory places another limit on the maximum size of a
213 usable segment: for example, on i386 the largest segments that can be mapped
214 have a size of around 2.8 GB, and on x86_64 the limit is around 127 TB.
215 .TP 
216 \fBSHMMIN\fP
217 共有メモリ・セグメントのバイト単位の大きさの下限: 実装依存 (現在は 1 バイトだが、実質的な最小サイズは \fBPAGE_SIZE\fP である)。
218 .TP 
219 \fBSHMMNI\fP
220 システム全体の共有メモリ・セグメント数の上限値。 この上限値のデフォルトは、 Linux 2.2 以降では 128、 Linux 2.4 以降で
221 4096 である。
222
223 .\" Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
224 .\" that we could create one more segment than SHMMNI -- MTK
225 .\" This /proc file is not available in Linux 2.2 and earlier -- MTK
226 Linux では、この上限値は \fI/proc/sys/kernel/shmmni\fP 経由で参照したり、変更したりできる。
227 .PP
228 プロセス当りの共有メモリ・セグメントの個数の最大値 (\fBSHMSEG\fP)  に関する実装上の制限はない。
229 .SS "Linux での注意"
230 バージョン 2.3.30 までは、Linux は 削除が予定されている共有メモリ・セグメントに対して \fBshmget\fP()  が行われると
231 \fBEIDRM\fP を返していた。
232 .SH バグ
233 \fBIPC_PRIVATE\fP という名前を選んだのはおそらく失敗であろう。 \fBIPC_NEW\fP の方がより明確にその機能を表しているだろう。
234 .SH 関連項目
235 \fBshmat\fP(2), \fBshmctl\fP(2), \fBshmdt\fP(2), \fBftok\fP(3), \fBcapabilities\fP(7),
236 \fBshm_overview\fP(7), \fBsvipc\fP(7)
237 .SH この文書について
238 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.76 の一部
239 である。プロジェクトの説明とバグ報告に関する情報は
240 http://www.kernel.org/doc/man\-pages/ に書かれている。