OSDN Git Service

Update release for LDP 3.67
[linuxjm/LDP_man-pages.git] / release / man2 / semget.2
1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
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 Tue Oct 22 17:54:56 1996 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified 1 Jan 2002, Martin Schulze <joey@infodrom.org>
27 .\" Modified 4 Jan 2002, Michael Kerrisk <mtk.manpages@gmail.com>
28 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\"     Added notes on capability requirements
30 .\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
31 .\"     Language and formatting clean-ups
32 .\"     Added notes on /proc files
33 .\"     Rewrote BUGS note about semget()'s failure to initialize
34 .\"             semaphore values
35 .\"
36 .\"*******************************************************************
37 .\"
38 .\" This file was generated with po4a. Translate the source file.
39 .\"
40 .\"*******************************************************************
41 .\"
42 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
43 .\"         all rights reserved.
44 .\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
45 .\" Updated 2003-04-08, Kentaro Shirakata <argrath@ub32.org>
46 .\" Updated 2005-03-01, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
47 .\" Updated 2006-07-20, Akihiro MOTOKI, LDP v2.36
48 .\" Updated 2013-05-01, Akihiro MOTOKI <amotoki@gmail.com>
49 .\"
50 .TH SEMGET 2 2014\-05\-21 Linux "Linux Programmer's Manual"
51 .SH 名前
52 semget \- System V セマフォ集合の識別子を取得する
53 .SH 書式
54 .nf
55 \fB#include <sys/types.h>\fP
56 \fB#include <sys/ipc.h>\fP
57 \fB#include <sys/sem.h>\fP
58 .fi
59 .sp
60 \fBint semget(key_t \fP\fIkey\fP\fB,\fP \fBint \fP\fInsems\fP\fB,\fP \fBint \fP\fIsemflg\fP\fB);\fP
61 .SH 説明
62 \fBsemget\fP()  システムコールは、引き数 \fIkey\fP に対応する System\ V セマフォ集合 (semaphore set) の
63 識別子 (identifier) を返す。 \fIkey\fP の値が \fBIPC_PRIVATE\fP の場合、もしくは \fIsemflg\fP に
64 \fBIPC_CREAT\fP が指定されていて、 \fIkey\fP に対応するセマフォ集合が存在しない場合、 \fInsems\fP
65 個のセマフォからなる新しい集合が作成される。
66 .PP
67 \fIsemflg\fP に \fBIPC_CREAT\fP と \fBIPC_EXCL\fP の両方が指定された場合、 \fIkey\fP
68 に対応するセマフォ集合が既に存在すると、 \fBsemget\fP()  は失敗し、 \fIerrno\fP に \fBEEXIST\fP が設定される (これは
69 \fBopen\fP(2)  に \fBO_CREAT | O_EXCL\fP が指定された場合の動作と同じである)。
70 .PP
71 セマフォ集合作成時に、引き数 \fIsemflg\fP の下位 9 ビットは、そのセマフォ集合の (所有者 (owner)、グループ (group)、 他人
72 (others) に対する) アクセス許可の定義として使用される。 これらのビットは \fBopen\fP(2)  の引き数 \fImode\fP
73 と同じ形式で同じ意味である (但し、実行 (execute) 許可はセマフォでは意味を持たず、 書き込み (write) 許可はセマフォ値の変更
74 (alter) 許可として機能する)。
75 .PP
76 新規のセマフォ集合を作成する際、 \fBsemget\fP()  はセマフォ集合の情報を保持するデータ構造体 \fIsemid_ds\fP を次のように初期化する
77 (\fIsemid_ds\fP については \fBsemctl\fP(2)  を参照):
78 .IP
79 \fIsem_perm.cuid\fP と \fIsem_perm.uid\fP に、呼び出し元のプロセスの実効 (effective) ユーザ ID を設定する。
80 .IP
81 \fIsem_perm.cgid\fP と \fIsem_perm.gid\fP に、呼び出し元のプロセスの実効 (effective) グループ ID
82 を設定する。
83 .IP
84 \fIsem_perm.mode\fP の下位 9 ビットに \fIsemflg\fP の下位 9 ビットを設定する。
85 .IP
86 \fIsem_nsems\fP に \fInsems\fP の値を設定する。
87 .IP
88 \fIsem_otime\fP に 0 を設定する。
89 .IP
90 \fIsem_ctime\fP に現在の時刻を設定する。
91 .PP
92 セマフォ集合の作成を行わない場合は、引き数 \fInsems\fP に (don't care を意味する) 0 を指定してもよい。 そうでない場合は、
93 \fInsems\fP は 0 より大きい値でなければならず、セマフォ集合あたりのセマフォの最大数 (\fBSEMMSL\fP)  以下でなければならない。
94 .PP
95 .\" and a check is made to see if it is marked for destruction.
96 セマフォ集合が既に存在した場合は、アクセス許可の検査が行われる。
97 .SH 返り値
98 成功した場合、セマフォ集合の識別子 (非負の整数) が返り値となる。 失敗した場合は \-1 が返され、 \fIerrno\fP にエラーを示す値が設定される。
99 .SH エラー
100 失敗した場合は \fIerrno\fP には以下の値のどれかが設定される:
101 .TP 
102 \fBEACCES\fP
103 \fIkey\fP に対応するセマフォ集合は存在するが、 呼び出し元のプロセスはその集合へのアクセス許可がなく、 \fBCAP_IPC_OWNER\fP
104 ケーパビリティも持っていない。
105 .TP 
106 \fBEEXIST\fP
107 .\" .TP
108 .\" .B EIDRM
109 .\" The semaphore set is marked to be deleted.
110 \fBIPC_CREAT\fP and \fBIPC_EXCL\fP were specified in \fIsemflg\fP, but a semaphore
111 set already exists for \fIkey\fP.
112 .TP 
113 \fBEINVAL\fP
114 \fInsems\fP is less than 0 or greater than the limit on the number of
115 semaphores per semaphore set (\fBSEMMSL\fP).
116 .TP 
117 \fBEINVAL\fP
118 A semaphore set corresponding to \fIkey\fP already exists, but \fInsems\fP is
119 larger than the number of semaphores in that set.
120 .TP 
121 \fBENOENT\fP
122 \fIkey\fP に対応するセマフォ集合が存在せず、 \fIsemflg\fP に \fBIPC_CREAT\fP が指定されてもいない。
123 .TP 
124 \fBENOMEM\fP
125 セマフォ集合を作成しようとしたが、新しいデータ構造体を 作成するのに十分なメモリがシステムに存在しない。
126 .TP 
127 \fBENOSPC\fP
128 セマフォ集合を作成しようとすると、システムのセマフォ集合の 最大数 (\fBSEMMNI\fP)  か、システム全体のセマフォの最大数 (\fBSEMMNS\fP)
129 のいずれかを超えてしまう。
130 .SH 準拠
131 .\" SVr4 documents additional error conditions EFBIG, E2BIG, EAGAIN,
132 .\" ERANGE, EFAULT.
133 SVr4, POSIX.1\-2001.
134 .SH 注意
135 .\" Like Linux, the FreeBSD man pages still document
136 .\" the inclusion of these header files.
137 Linux や POSIX の全てのバージョンでは、 \fI<sys/types.h>\fP と \fI<sys/ipc.h>\fP
138 のインクルードは必要ない。しかしながら、いくつかの古い実装ではこれらのヘッダファイルのインクルードが必要であり、 SVID
139 でもこれらのインクルードをするように記載されている。このような古いシステムへの移植性を意図したアプリケーションではこれらのファイルをインクルードする必要があるかもしれない。
140
141 .\"
142 \fBIPC_PRIVATE\fP はフラグ・フィールドに指定するものではなく、 \fIkey_t\fP 型である。 この特別な値が \fIkey\fP に指定されると、
143 \fBsemget\fP()  \fIsemflg\fP の下位 9 ビット以外は全て無視し、 (成功した場合は) 新しいセマフォ集合を作成する。
144 .SS "Semaphore initialization"
145 .\" In truth, every one of the many implementations that I've tested sets
146 .\" the values to zero, but I suppose there is/was some obscure
147 .\" implementation out there that does not.
148 The values of the semaphores in a newly created set are indeterminate.
149 (POSIX.1\-2001 and POSIX.1\-2008 are explicit on this point, although
150 POSIX.1\-2008 notes that a future version of the standard may require an
151 implementation to initialize the semaphores to 0.)  Although Linux, like
152 many other implementations, initializes the semaphore values to 0, a
153 portable application cannot rely on this: it should explicitly initialize
154 the semaphores to the desired values.
155
156 .\"
157 Initialization can be done using \fBsemctl\fP(2)  \fBSETVAL\fP or \fBSETALL\fP
158 operation.  Where multiple peers do not know who will be the first to
159 initialize the set, checking for a nonzero \fIsem_otime\fP in the associated
160 data structure retrieved by a \fBsemctl\fP(2)  \fBIPC_STAT\fP operation can be
161 used to avoid races.
162 .SS "Semaphore limits"
163 セマフォ集合のリソースに関する制限のうち、 \fBsemget\fP()  に影響を及ぼすものを以下に挙げる:
164 .TP 
165 \fBSEMMNI\fP
166 .\" This /proc file is not available in Linux 2.2 and earlier -- MTK
167 System\-wide limit on the number of semaphore sets: policy dependent (on
168 Linux, this limit can be read and modified via the fourth field of
169 \fI/proc/sys/kernel/sem\fP).
170 .TP 
171 \fBSEMMSL\fP
172 セマフォ ID あたりのセマフォの最大数: 実装依存 (Linux では、この制限値は \fI/proc/sys/kernel/sem\fP
173 の第1フィールドに対応し、読み出しも変更もできる)。
174 .TP 
175 \fBSEMMNS\fP
176 System\-wide limit on the number of semaphores: policy dependent (on Linux,
177 this limit can be read and modified via the second field of
178 \fI/proc/sys/kernel/sem\fP).  Note that number of semaphores system\-wide is
179 also limited by the product of \fBSEMMSL\fP and \fBSEMMNI\fP.
180 .SH バグ
181 \fBIPC_PRIVATE\fP という名前を選んだのはおそらく失敗であろう。 \fBIPC_NEW\fP の方がより明確にその機能を表しているだろう。
182 .SH 関連項目
183 \fBsemctl\fP(2), \fBsemop\fP(2), \fBftok\fP(3), \fBcapabilities\fP(7),
184 \fBsem_overview\fP(7), \fBsvipc\fP(7)
185 .SH この文書について
186 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
187 である。プロジェクトの説明とバグ報告に関する情報は
188 http://www.kernel.org/doc/man\-pages/ に書かれている。