OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / draft / man2 / shmget.2
1 .\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Modified Wed Jul 28 10:57:35 1993, Rik Faith <faith@cs.unc.edu>
24 .\" Modified Sun Nov 28 16:43:30 1993, Rik Faith <faith@cs.unc.edu>
25 .\"          with material from Giorgio Ciucci <giorgio@crcc.it>
26 .\" Portions Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
27 .\" Modified Tue Oct 22 22:03:17 1996 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified, 8 Jan 2003, Michael Kerrisk, <mtk.manpages@gmail.com>
29 .\"     Removed EIDRM from errors - that can't happen...
30 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Added notes on capability requirements
32 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\"     Language and formatting clean-ups
34 .\"     Added notes on /proc files
35 .\"
36 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
37 .\"         all rights reserved.
38 .\" Translated 1997-03-01, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
39 .\" Updated & Modified 2001-06-03, Yuichi SATO <ysato@h4.dion.ne.jp>
40 .\" Updated 2001-12-22, Kentaro Shirakata <argrath@ub32.org>
41 .\" Updated 2002-10-16, Kentaro Shirakata <argrath@ub32.org>
42 .\" Updated 2003-02-23, Kentaro Shirakata <argrath@ub32.org>
43 .\" Updated 2005-03-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2005-11-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
46 .\"
47 .\"WORD:        shared memory           共有メモリ
48 .\"WORD:        segment                 セグメント
49 .\"WORD:        owner                   所有者
50 .\"WORD:        group                   グループ
51 .\"WORD:        world                   他人
52 .\"WORD:        creator                 作成者
53 .\"WORD:        super-user              スーパー・ユーザー
54 .\"WORD:        detach                  分離
55 .\"WORD:        attach                  付加
56 .\"WORD:        identifier              識別子
57 .\"WORD:        member                  メンバー
58 .\"WORD:        effective user ID       実効ユーザーID
59 .\"WORD:        effective group ID      実効グループID
60 .\"WORD:        policy                  方針
61 .\"WORD:        implement               実装
62 .\"
63 .TH SHMGET 2 2006-05-02 "Linux" "Linux Programmer's Manual"
64 .\"O .SH NAME
65 .SH 名前
66 .\"O shmget \- allocates a shared memory segment
67 shmget \- 共有メモリ・セグメントを割り当てる
68 .\"O .SH SYNOPSIS
69 .SH 書式
70 .ad l
71 .B #include <sys/ipc.h>
72 .br
73 .B #include <sys/shm.h>
74 .sp
75 .BI "int shmget(key_t " key ", size_t " size ", int " shmflg );
76 .ad b
77 .\"O .SH DESCRIPTION
78 .SH 説明
79 .\"O .BR shmget ()
80 .\"O returns the identifier of the shared memory segment
81 .\"O associated with the value of the argument
82 .\"O .IR key .
83 .\"O A new shared memory segment, with size equal to the value of
84 .\"O .I size
85 .\"O rounded up to a multiple of
86 .\"O .BR PAGE_SIZE ,
87 .\"O is created if
88 .\"O .I key
89 .\"O has the value
90 .\"O .B IPC_PRIVATE
91 .\"O or
92 .\"O .I key
93 .\"O isn't
94 .\"O .BR IPC_PRIVATE ,
95 .\"O no shared memory segment corresponding to
96 .\"O .I key
97 .\"O exists, and
98 .\"O .B IPC_CREAT
99 .\"O is specified in
100 .\"O .IR shmflg .
101 .BR shmget ()
102
103 .I key
104 引き数に対応する共有メモリ・セグメントの識別子を返す。
105 .I key
106 の値が
107 .B IPC_PRIVATE
108 の場合、もしくは
109 .I key
110 に対応する共有メモリ・セグメントが存在せず、
111 .I shmflg
112
113 .B IPC_CREAT
114 が指定されていた場合、
115 新しい共有メモリ・セグメントを作成する。
116 作成される共有メモリ・セグメントは、
117 .I size
118 引き数の値を
119 .B PAGE_SIZE
120 の倍数へと切り上げた (round up) 大きさとなる。
121 .PP
122 .\"O If
123 .\"O .I shmflg
124 .\"O specifies both
125 .\"O .B IPC_CREAT
126 .\"O and
127 .\"O .B IPC_EXCL
128 .\"O and a shared memory segment already exists for
129 .\"O .IR key ,
130 .\"O then
131 .\"O .BR shmget ()
132 .\"O fails with
133 .\"O .I errno
134 .\"O set to
135 .\"O .BR EEXIST .
136 .\"O (This is analogous to the effect of the combination
137 .\"O .B O_CREAT | O_EXCL
138 .\"O for
139 .\"O .BR open (2).)
140 .I shmflg
141
142 .B IPC_CREAT
143
144 .B IPC_EXCL
145 の両方が指定された場合、
146 .I key
147 に対応する共有メモリ・セグメントが既に存在すると、
148 .BR shmget ()
149 は失敗し、
150 .I errno
151
152 .B EEXIST
153 が設定される (これは
154 .BR open (2)
155
156 .B O_CREAT | O_EXCL
157 を指定した場合の動作と同じである)。
158 .PP
159 .\"O The value
160 .\"O .I shmflg
161 .\"O is composed of:
162 .I shmflg
163 は以下の内容から構成される:
164 .TP 12
165 .B IPC_CREAT
166 .\"O to create a new segment.
167 .\"O If this flag is not used, then
168 .\"O .BR shmget ()
169 .\"O will find the segment associated with \fIkey\fP and check to see if
170 .\"O the user has permission to access the segment.
171 新しいセグメントを作成する。このフラグが指定されなかった場合、
172 .BR shmget ()
173 は \fIkey\fP に対応するセグメントを探し、
174 ユーザがそのセグメントにアクセスする許可があるかどうかをチェックする。
175 .TP
176 .B IPC_EXCL
177 .\"O used with \fBIPC_CREAT\fP to ensure failure if the segment already exists.
178 \fBIPC_CREAT\fP と共に使用し、セグメントが既に存在した場合には
179 失敗することを保証する。
180 .TP
181 .I mode_flags
182 .\"O (least significant 9 bits)
183 (下位 9 ビット)
184 .\"O specifying the permissions granted to the owner, group, and world.
185 .\"O These bits have the same format, and the same
186 .\"O meaning, as the
187 .\"O .I mode
188 .\"O argument of
189 .\"O .BR open (2).
190 .\"O Presently, the execute permissions are not used by the system.
191 所有者、グループ、他人 (world) への許可を指定する。
192 これらのビットは
193 .BR open (2)
194
195 .I mode
196 引き数と同じ形式で同じ意味を持つ。
197 今のところ、システムは実行 (execute) 許可を参照しない。
198 .TP
199 .\"O .BR SHM_HUGETLB " (since Linux 2.6)"
200 .BR SHM_HUGETLB " (Linux 2.6 以降)"
201 .\"O Allocate the segment using "huge pages."
202 .\"O See the kernel source file
203 .\"O .I Documentation/vm/hugetlbpage.txt
204 .\"O for further information.
205 "ヒュージページ (huge page)" を使うセグメントを割り当てる。
206 詳細な情報は、カーネル・ソースのファイル
207 .I Documentation/vm/hugetlbpage.txt
208 を参照。
209 .TP
210 .\"O .BR SHM_NORESERVE " (since Linux 2.6.15)"
211 .BR SHM_NORESERVE " (Linux 2.6.15 以降)"
212 .\"O This flag serves the same purpose as the
213 .\"O .BR mmap (2)
214 .\"O .B MAP_NORESERVE
215 .\"O flag.
216 このフラグは、
217 .BR mmap (2)
218
219 .B MAP_NORESERVE
220 フラグと同じ役割を果たす。
221 .\"O Do not reserve swap space for this segment.
222 .\"O When swap space is reserved, one has the guarantee
223 .\"O that it is possible to modify the segment.
224 .\"O When swap space is not reserved one might get
225 .\"O .B SIGSEGV
226 .\"O upon a write
227 .\"O if no physical memory is available.
228 このセグメントに対するスワップ空間の予約を行わない。
229 スワップ空間を予約した場合は、そのセグメントの変更が必ず成功することが
230 保証される。スワップ空間の予約を行わなかった場合は、物理メモリに空きが
231 ないと書き込み時に
232 .B SIGSEGV
233 を受け取る可能性がある。
234 .\"O See also the discussion of the file
235 .\"O .I /proc/sys/vm/overcommit_memory
236 .\"O in
237 .\"O .BR proc (5).
238 .BR proc (5)
239 にある
240 .I /proc/sys/vm/overcommit_memory
241 ファイルに関する議論も参照のこと。
242 .\" As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
243 .\" specified.
244 .PP
245 .\"O When a new shared memory segment is created,
246 .\"O its contents are initialized to zero values, and
247 .\"O its associated data structure,
248 .\"O .I shmid_ds
249 .\"O (see
250 .\"O .BR shmctl (2)),
251 .\"O is initialized as follows:
252 共有メモリ・セグメントが新たに作成される際、
253 共有メモリ・セグメントの内容は 0 で初期化され、
254 関連情報を保持するデータ構造体
255 .I shmid_ds
256 は以下のように初期化される。
257 .IP
258 .\"O .I shm_perm.cuid
259 .\"O and
260 .\"O .I shm_perm.uid
261 .\"O are set to the effective user ID of the calling process.
262 .I shm_perm.cuid
263
264 .I shm_perm.uid
265 に呼び出し元プロセスの実効 (effective) ユーザーID を設定する。
266 .IP
267 .\"O .I shm_perm.cgid
268 .\"O and
269 .\"O .I shm_perm.gid
270 .\"O are set to the effective group ID of the calling process.
271 .I shm_perm.cgid
272
273 .I shm_perm.gid
274 に呼び出し元プロセスの実効グループID を設定する。
275 .IP
276 .\"O The least significant 9 bits of
277 .\"O .I shm_perm.mode
278 .\"O are set to the least significant 9 bit of
279 .\"O .IR shmflg .
280 .I shm_perm.mode
281 の下位 9 ビットに
282 .I shmflg
283 の下位 9 ビットを設定する。
284 .IP
285 .\"O .I shm_segsz
286 .\"O is set to the value of
287 .\"O .IR size .
288 .I shm_segsz
289
290 .I size
291 の値を設定する。
292 .IP
293 .\"O .IR shm_lpid ,
294 .\"O .IR shm_nattch ,
295 .\"O .I shm_atime
296 .\"O and
297 .\"O .I shm_dtime
298 .\"O are set to 0.
299 .IR shm_lpid ,
300 .IR shm_nattch ,
301 .IR shm_atime ,
302 .I shm_dtime
303 に 0 を設定する。
304 .IP
305 .\"O .I shm_ctime
306 .\"O is set to the current time.
307 .I shm_ctime
308 に現在の時刻を設定する。
309 .PP
310 .\"O If the shared memory segment already exists, the permissions are
311 .\"O verified, and a check is made to see if it is marked for destruction.
312 共有メモリ・セグメントが既に存在する場合、アクセス許可の検査と、
313 破壊 (destruction) マークがつけられていないかのチェックが行われる。
314 .\"O .SH "RETURN VALUE"
315 .SH 返り値
316 .\"O A valid segment identifier,
317 .\"O .IR shmid ,
318 .\"O is returned on success, \-1 on error.
319 成功した場合、有効なセグメント識別子
320 .I shmid
321 が返される。エラーの場合、 \-1 が返される。
322 .\"O .SH ERRORS
323 .SH エラー
324 .\"O On failure,
325 .\"O .I errno
326 .\"O is set to one of the following:
327 失敗した場合は
328 .I errno
329 が以下のどれかに設定される:
330 .TP
331 .B EACCES
332 .\"O The user does not have permission to access the
333 .\"O shared memory segment, and does not have the
334 .\"O .B CAP_IPC_OWNER
335 .\"O capability.
336 ユーザーはその共有メモリ・セグメントへのアクセス許可を持たず、
337 .B CAP_IPC_OWNER
338 ケーパビリティも持っていない。
339 .TP
340 .B EEXIST
341 .\"O .B IPC_CREAT | IPC_EXCL
342 .\"O was specified and the segment exists.
343 .B IPC_CREAT | IPC_EXCL
344 が指定されていたが、そのセグメントが既に存在する。
345 .TP
346 .B EINVAL
347 .\"O A new segment was to be created and \fIsize\fP < \fBSHMMIN\fP
348 .\"O or \fIsize\fP > \fBSHMMAX\fP, or no new segment was to be created,
349 .\"O a segment with given key existed, but \fIsize\fP is greater than the size
350 .\"O of that segment.
351 新しいセグメントを作成しようとした際に
352 \fIsize\fP < \fBSHMMIN\fP または \fIsize\fP > \fBSHMMAX\fP であった。
353 もしくは、指定されたキーに対応するセグメントが既に存在して、新しい
354 セグメントを作成しようとはしなかったが、\fIsize\fP が存在するセグメントの
355 サイズよりも大きかった。
356 .TP
357 .B ENFILE
358 .\"O .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
359 .\"O The system limit on the total number of open files has been reached.
360 .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
361 システム全体でオープンされているファイルの総数が上限に達した。
362 .TP
363 .B ENOENT
364 .\"O No segment exists for the given \fIkey\fP, and
365 .\"O .B IPC_CREAT
366 .\"O was not specified.
367 指定された \fIkey\fP に対応するセグメントが存在せず、
368 .B IPC_CREAT
369 も指定されていなかった。
370 .TP
371 .B ENOMEM
372 .\"O No memory could be allocated for segment overhead.
373 セグメントの管理情報 (overhead) に割り当てるメモリがなかった。
374 .TP
375 .B ENOSPC
376 .\"O All possible shared memory ID's have been taken
377 .\"O .RB ( SHMMNI ),
378 .\"O or allocating a segment of the requested
379 .\"O .I size
380 .\"O would cause the system to exceed the system-wide limit on shared memory
381 .\"O .RB ( SHMALL ).
382 .\" motoki 2005-03-02 -- SHMMNI の意味を考慮して意訳
383 システム全体の共有メモリ・セグメント数の制限
384 .RB ( SHMMNI )
385 に達した、または要求された
386 .I size
387 のセグメントの割り当てが
388 システム全体の共有メモリサイズの制限
389 .RB ( SHMALL )
390 を超過した。
391 .TP
392 .B EPERM
393 .\"O The
394 .\"O .B SHM_HUGETLB
395 .\"O flag was specified, but the caller was not privileged (did not have the
396 .\"O .B CAP_IPC_LOCK
397 .\"O capability).
398 .B SHM_HUGETLB
399 フラグが指定されたが、呼び出し元には権限がなかった
400 .RB ( CAP_IPC_LOCK
401 ケーパビリティを持っていなかった)。
402 .\"O .SH "CONFORMING TO"
403 .SH 準拠
404 SVr4, POSIX.1-2001.
405 .\"O .\" SVr4 documents an additional error condition EEXIST.
406 .\" SVr4 には追加で EEXIST エラー状態の記述がある。
407
408 .\"O .B SHM_HUGETLB
409 .\"O is a nonportable Linux extension.
410 .B SHM_HUGETLB
411 は Linux での拡張であり、移植性はない。
412 .\"O .SH NOTES
413 .SH 注意
414 .\"O .B IPC_PRIVATE
415 .\"O isn't a flag field but a
416 .\"O .I key_t
417 .\"O type.
418 .B IPC_PRIVATE
419 はフラグではなく
420 .I key_t
421 型である。
422 .\"O If this special value is used for
423 .\"O .IR key ,
424 .\"O the system call ignores everything but the least significant 9 bits of
425 .\"O .I shmflg
426 .\"O and creates a new shared memory segment (on success).
427 この特別な値が
428 .I key
429 に使用された場合は、
430 .BR shmget ()
431
432 .I shmflg
433 の下位 9 ビットを除いた全てを無視し、
434 (成功すれば) 新しい共有メモリ・セグメントを作成する。
435 .PP
436 .\"O The following limits on shared memory segment resources affect the
437 .\"O .BR shmget ()
438 .\"O call:
439 .BR shmget ()
440 コールに影響する共有メモリ・セグメント資源の制限は以下の通りである:
441 .TP
442 .B SHMALL
443 .\"O System wide maximum of shared memory pages
444 .\"O (on Linux, this limit can be read and modified via
445 .\"O .IR /proc/sys/kernel/shmall ).
446 システム全体の共有メモリ・ページの最大数
447 (Linux では、この上限値は
448 .I /proc/sys/kernel/shmall
449 経由で参照したり、変更したりできる)。
450 .TP
451 .B SHMMAX
452 .\"O Maximum size in bytes for a shared memory segment: policy dependent
453 .\"O (on Linux, this limit can be read and modified via
454 .\"O .IR /proc/sys/kernel/shmmax ).
455 共有メモリ・セグメントのバイト単位の大きさの上限: 方針依存
456 (Linux では、この上限値は
457 .I /proc/sys/kernel/shmmax
458 経由で参照したり、変更したりできる)。
459 .TP
460 .B SHMMIN
461 .\"O Minimum size in bytes for a shared memory segment: implementation
462 .\"O dependent (currently 1 byte, though
463 .\"O .B PAGE_SIZE
464 .\"O is the effective minimum size).
465 共有メモリ・セグメントのバイト単位の大きさの下限: 実装依存
466 (現在は 1 バイトだが、実質的な最小サイズは
467 .B PAGE_SIZE
468 である)。
469 .TP
470 .B SHMMNI
471 .\"O System wide maximum number of shared memory segments: implementation
472 .\"O dependent (currently 4096, was 128 before Linux 2.3.99;
473 .\"O on Linux, this limit can be read and modified via
474 .\"O .IR /proc/sys/kernel/shmmni ).
475 .\"O .\" Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
476 .\"O .\" that we could create one more segment than SHMMNI -- MTK
477 .\"O .\" This /proc file is not available in Linux 2.2 and earlier -- MTK
478 システム全体の共有メモリーの数の上限: 実装依存
479 (現在は 4096。Linux 2.3.99 より前では 128。
480 Linux では、この上限値は
481 .I /proc/sys/kernel/shmmni
482 経由で参照したり、変更したりできる)。
483 .\" 2.4.x と 2.6.8 の間のカーネルには、SHMMNI より一つの多くの
484 .\" セグメントを作成できるというバグがあった。
485 .\" この /proc ファイルは Linux 2.2 以前では利用できない -- MTK
486 .PP
487 .\"O The implementation has no specific limits for the per-process maximum
488 .\"O number of shared memory segments
489 .\"O .RB ( SHMSEG ).
490 プロセス当りの共有メモリ・セグメントの個数の最大値
491 .RB ( SHMSEG )
492 に関する実装上の制限はない。
493 .\"O .SS LINUX NOTES
494 .\"O Until version 2.3.30 Linux would return
495 .\"O .B EIDRM
496 .\"O for a
497 .\"O .BR shmget ()
498 .\"O on a shared memory segment scheduled for deletion.
499 .SS Linux での注意
500 バージョン 2.3.30 までは、Linux は
501 削除が予定されている共有メモリ・セグメントに対して
502 .BR shmget ()
503 が行われると
504 .B EIDRM
505 を返していた。
506 .\"O .SH BUGS
507 .SH バグ
508 .\"O The name choice
509 .\"O .B IPC_PRIVATE
510 .\"O was perhaps unfortunate,
511 .\"O .B IPC_NEW
512 .\"O would more clearly show its function.
513 .B IPC_PRIVATE
514 という名前を選んだのはおそらく失敗であろう。
515 .B IPC_NEW
516 の方がより明確にその機能を表しているだろう。
517 .\"O .SH "SEE ALSO"
518 .SH 関連項目
519 .BR shmat (2),
520 .BR shmctl (2),
521 .BR shmdt (2),
522 .BR ftok (3),
523 .BR capabilities (7),
524 .BR shm_overview (7),
525 .BR svipc (7)