OSDN Git Service

(split) LDP: draft snapshots from latest ja.po(s).
[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 .\"*******************************************************************
37 .\"
38 .\" This file was generated with po4a. Translate the source file.
39 .\"
40 .\"*******************************************************************
41 .TH SHMGET 2 2006\-05\-02 Linux "Linux Programmer's Manual"
42 .SH 名前
43 shmget \- 共有メモリ・セグメントを割り当てる
44 .SH 書式
45 .ad l
46 \fB#include <sys/ipc.h>\fP
47 .br
48 \fB#include <sys/shm.h>\fP
49 .sp
50 \fBint shmget(key_t \fP\fIkey\fP\fB, size_t \fP\fIsize\fP\fB, int \fP\fIshmflg\fP\fB);\fP
51 .ad b
52 .SH 説明
53 \fBshmget\fP()  は \fIkey\fP 引き数に対応する共有メモリ・セグメントの識別子を返す。 \fIkey\fP の値が \fBIPC_PRIVATE\fP
54 の場合、もしくは \fIkey\fP に対応する共有メモリ・セグメントが存在せず、 \fIshmflg\fP に \fBIPC_CREAT\fP が指定されていた場合、
55 新しい共有メモリ・セグメントを作成する。 作成される共有メモリ・セグメントは、 \fIsize\fP 引き数の値を \fBPAGE_SIZE\fP
56 の倍数へと切り上げた (round up) 大きさとなる。
57 .PP
58 \fIshmflg\fP に \fBIPC_CREAT\fP と \fBIPC_EXCL\fP の両方が指定された場合、 \fIkey\fP
59 に対応する共有メモリ・セグメントが既に存在すると、 \fBshmget\fP()  は失敗し、 \fIerrno\fP に \fBEEXIST\fP が設定される
60 (これは \fBopen\fP(2)  に \fBO_CREAT | O_EXCL\fP を指定した場合の動作と同じである)。
61 .PP
62 \fIshmflg\fP は以下の内容から構成される:
63 .TP  12
64 \fBIPC_CREAT\fP
65 新しいセグメントを作成する。このフラグが指定されなかった場合、 \fBshmget\fP()  は \fIkey\fP に対応するセグメントを探し、
66 ユーザがそのセグメントにアクセスする許可があるかどうかをチェックする。
67 .TP 
68 \fBIPC_EXCL\fP
69 \fBIPC_CREAT\fP と共に使用し、セグメントが既に存在した場合には 失敗することを保証する。
70 .TP 
71 \fImode_flags\fP
72 (下位 9 ビット)  所有者、グループ、他人 (world) への許可を指定する。 これらのビットは \fBopen\fP(2)  の \fImode\fP
73 引き数と同じ形式で同じ意味を持つ。 今のところ、システムは実行 (execute) 許可を参照しない。
74 .TP 
75 \fBSHM_HUGETLB\fP (Linux 2.6 以降)
76 "ヒュージページ (huge page)" を使うセグメントを割り当てる。 詳細な情報は、カーネル・ソースのファイル
77 \fIDocumentation/vm/hugetlbpage.txt\fP を参照。
78 .TP 
79 \fBSHM_NORESERVE\fP (Linux 2.6.15 以降)
80 .\" As at 2.6.17-rc2, this flag has no effect if SHM_HUGETLB was also
81 .\" specified.
82 このフラグは、 \fBmmap\fP(2)  の \fBMAP_NORESERVE\fP フラグと同じ役割を果たす。
83 このセグメントに対するスワップ空間の予約を行わない。 スワップ空間を予約した場合は、そのセグメントの変更が必ず成功することが
84 保証される。スワップ空間の予約を行わなかった場合は、物理メモリに空きが ないと書き込み時に \fBSIGSEGV\fP を受け取る可能性がある。
85 \fBproc\fP(5)  にある \fI/proc/sys/vm/overcommit_memory\fP ファイルに関する議論も参照のこと。
86 .PP
87 共有メモリ・セグメントが新たに作成される際、 共有メモリ・セグメントの内容は 0 で初期化され、 関連情報を保持するデータ構造体 \fIshmid_ds\fP
88 は以下のように初期化される。
89 .IP
90 \fIshm_perm.cuid\fP と \fIshm_perm.uid\fP に呼び出し元プロセスの実効 (effective) ユーザーID を設定する。
91 .IP
92 \fIshm_perm.cgid\fP と \fIshm_perm.gid\fP に呼び出し元プロセスの実効グループID を設定する。
93 .IP
94 \fIshm_perm.mode\fP の下位 9 ビットに \fIshmflg\fP の下位 9 ビットを設定する。
95 .IP
96 \fIshm_segsz\fP に \fIsize\fP の値を設定する。
97 .IP
98 \fIshm_lpid\fP, \fIshm_nattch\fP, \fIshm_atime\fP, \fIshm_dtime\fP に 0 を設定する。
99 .IP
100 \fIshm_ctime\fP に現在の時刻を設定する。
101 .PP
102 共有メモリ・セグメントが既に存在する場合、アクセス許可の検査と、 破壊 (destruction) マークがつけられていないかのチェックが行われる。
103 .SH 返り値
104 成功した場合、有効なセグメント識別子 \fIshmid\fP が返される。エラーの場合、 \-1 が返される。
105 .SH エラー
106 失敗した場合は \fIerrno\fP が以下のどれかに設定される:
107 .TP 
108 \fBEACCES\fP
109 ユーザーはその共有メモリ・セグメントへのアクセス許可を持たず、 \fBCAP_IPC_OWNER\fP ケーパビリティも持っていない。
110 .TP 
111 \fBEEXIST\fP
112 \fBIPC_CREAT | IPC_EXCL\fP が指定されていたが、そのセグメントが既に存在する。
113 .TP 
114 \fBEINVAL\fP
115 新しいセグメントを作成しようとした際に \fIsize\fP < \fBSHMMIN\fP または \fIsize\fP > \fBSHMMAX\fP
116 であった。 もしくは、指定されたキーに対応するセグメントが既に存在して、新しい セグメントを作成しようとはしなかったが、\fIsize\fP
117 が存在するセグメントの サイズよりも大きかった。
118 .TP 
119 \fBENFILE\fP
120 .\" [2.6.7] shmem_zero_setup()-->shmem_file_setup()-->get_empty_filp()
121 システム全体でオープンされているファイルの総数が上限に達した。
122 .TP 
123 \fBENOENT\fP
124 指定された \fIkey\fP に対応するセグメントが存在せず、 \fBIPC_CREAT\fP も指定されていなかった。
125 .TP 
126 \fBENOMEM\fP
127 セグメントの管理情報 (overhead) に割り当てるメモリがなかった。
128 .TP 
129 \fBENOSPC\fP
130 システム全体の共有メモリ・セグメント数の制限 (\fBSHMMNI\fP)  に達した、または要求された \fIsize\fP のセグメントの割り当てが
131 システム全体の共有メモリサイズの制限 (\fBSHMALL\fP)  を超過した。
132 .TP 
133 \fBEPERM\fP
134 \fBSHM_HUGETLB\fP フラグが指定されたが、呼び出し元には権限がなかった (\fBCAP_IPC_LOCK\fP ケーパビリティを持っていなかった)。
135 .SH 準拠
136 .\" SVr4 documents an additional error condition EEXIST.
137 SVr4, POSIX.1\-2001.
138
139 \fBSHM_HUGETLB\fP は Linux での拡張であり、移植性はない。
140 .SH 注意
141 \fBIPC_PRIVATE\fP はフラグではなく \fIkey_t\fP 型である。 この特別な値が \fIkey\fP に使用された場合は、 \fBshmget\fP()
142 は \fIshmflg\fP の下位 9 ビットを除いた全てを無視し、 (成功すれば) 新しい共有メモリ・セグメントを作成する。
143 .PP
144 \fBshmget\fP()  コールに影響する共有メモリ・セグメント資源の制限は以下の通りである:
145 .TP 
146 \fBSHMALL\fP
147 システム全体の共有メモリ・ページの最大数 (Linux では、この上限値は \fI/proc/sys/kernel/shmall\fP
148 経由で参照したり、変更したりできる)。
149 .TP 
150 \fBSHMMAX\fP
151 共有メモリ・セグメントのバイト単位の大きさの上限: 方針依存 (Linux では、この上限値は \fI/proc/sys/kernel/shmmax\fP
152 経由で参照したり、変更したりできる)。
153 .TP 
154 \fBSHMMIN\fP
155 共有メモリ・セグメントのバイト単位の大きさの下限: 実装依存 (現在は 1 バイトだが、実質的な最小サイズは \fBPAGE_SIZE\fP である)。
156 .TP 
157 \fBSHMMNI\fP
158 .\" Kernels between 2.4.x and 2.6.8 had an off-by-one error that meant
159 .\" that we could create one more segment than SHMMNI -- MTK
160 .\" This /proc file is not available in Linux 2.2 and earlier -- MTK
161 システム全体の共有メモリーの数の上限: 実装依存 (現在は 4096。Linux 2.3.99 より前では 128。 Linux では、この上限値は
162 \fI/proc/sys/kernel/shmmni\fP 経由で参照したり、変更したりできる)。
163 .PP
164 プロセス当りの共有メモリ・セグメントの個数の最大値 (\fBSHMSEG\fP)  に関する実装上の制限はない。
165 .SS "Linux での注意"
166 バージョン 2.3.30 までは、Linux は 削除が予定されている共有メモリ・セグメントに対して \fBshmget\fP()  が行われると
167 \fBEIDRM\fP を返していた。
168 .SH バグ
169 \fBIPC_PRIVATE\fP という名前を選んだのはおそらく失敗であろう。 \fBIPC_NEW\fP の方がより明確にその機能を表しているだろう。
170 .SH 関連項目
171 \fBshmat\fP(2), \fBshmctl\fP(2), \fBshmdt\fP(2), \fBftok\fP(3), \fBcapabilities\fP(7),
172 \fBshm_overview\fP(7), \fBsvipc\fP(7)
173 .SH この文書について
174 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部
175 である。プロジェクトの説明とバグ報告に関する情報は
176 http://www.kernel.org/doc/man\-pages/ に書かれている。