OSDN Git Service

fae839e0492b553fad516c1ff3feebede1b4b541
[linuxjm/LDP_man-pages.git] / draft / man3 / sem_open.3
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
27 .\" Translated 2006-04-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\" Updated 2009-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.19
29 .\"
30 .TH SEM_OPEN 3 2009-02-20 "Linux" "Linux Programmer's Manual"
31 .\"O .SH NAME
32 .SH 名前
33 .\"O sem_open \- initialize and open a named semaphore
34 sem_open \- 名前付きセマフォを初期化し、オープンする
35 .\"O .SH SYNOPSIS
36 .SH 書式
37 .nf
38 .BR "#include <fcntl.h>" "           /* For O_* constants */"
39 .BR "#include <sys/stat.h>" "        /* For mode constants */"
40 .B #include <semaphore.h>
41 .sp
42 .BI "sem_t *sem_open(const char *" name ", int " oflag );
43 .BI "sem_t *sem_open(const char *" name ", int " oflag ", "
44 .BI "                mode_t " mode ", unsigned int " value );
45 .fi
46 .sp
47 .\"O Link with \fI\-lrt\fP or \fI\-pthread\fP.
48 \fI\-lrt\fP または \fI\-pthread\fP でリンクする。
49 .\"O .SH DESCRIPTION
50 .SH 説明
51 .\"O .BR sem_open ()
52 .\"O creates a new POSIX semaphore or opens an existing semaphore.
53 .\"O The semaphore is identified by
54 .\"O .IR name .
55 .\"O For details of the construction of
56 .\"O .IR name ,
57 .\"O see
58 .\"O .BR sem_overview (7).
59 .BR sem_open ()
60 は、新規の POSIX セマフォを作成するか、既存のセマフォのオープンを行う。
61 セマフォは
62 .I name
63 で識別される。
64 .I name
65 の構成の詳細は
66 .BR sem_overview (7)
67 を参照。
68
69 .\"O The
70 .\"O .I oflag
71 .\"O argument specifies flags that control the operation of the call.
72 .\"O (Definitions of the flags values can be obtained by including
73 .\"O .IR <fcntl.h> .)
74 .I oflag
75 引き数には、
76 .BR sem_open ()
77 の動作を制御するフラグを指定する
78 (oflag の値の定義は
79 .I <fcntl.h>
80 のインクルードにより得られる)。
81 .\"O If
82 .\"O .B O_CREAT
83 .\"O is specified in
84 .\"O .IR oflag ,
85 .\"O then the semaphore is created if
86 .\"O it does not already exist.
87 .\"O The owner (user ID) of the semaphore is set to the effective
88 .\"O user ID of the calling process.
89 .\"O The group ownership (group ID) is set to the effective group ID
90 .\"O of the calling process.
91 .\"O .\" In reality the file system IDs are used on Linux.
92 .I oflag
93
94 .B O_CREAT
95 が指定されると、まだ存在しない場合にはそのセマフォが作成される。
96 セマフォの所有者 (ユーザ ID)、グループ所有権 (グループ ID) には、
97 それぞれ呼び出し元プロセスの実効 UID、実効 GID が設定される。
98 .\" 実際は、Linux ではファイルシステム ID が使用される。
99 .\"O If both
100 .\"O .B O_CREAT
101 .\"O and
102 .\"O .B O_EXCL
103 .\"O are specified in
104 .\"O .IR oflag ,
105 .\"O then an error is returned if a semaphore with the given
106 .\"O .I name
107 .\"O already exists.
108 .I oflag
109
110 .B O_CREAT
111
112 .B O_EXCL
113 の両方が指定された場合、指定された名前
114 .I name
115 のセマフォがすでに存在するとエラーが返される。
116 .PP
117 .\"O If
118 .\"O .B O_CREAT
119 .\"O is specified in
120 .\"O .IR oflag ,
121 .\"O then two additional arguments must be supplied.
122 .I oflag
123
124 .B O_CREAT
125 を指定する場合、さらに引き数が 2 つ必要である。
126 .\"O The
127 .\"O .I mode
128 .\"O argument specifies the permissions to be placed on the new semaphore,
129 .\"O as for
130 .\"O .BR open (2).
131 .\"O (Symbolic definitions for the permissions bits can be obtained by including
132 .\"O .IR <sys/stat.h> .)
133 .\"O The permissions settings are masked against the process umask.
134 .\"O Both read and write permission should be granted to each class of
135 .\"O user that will access the semaphore.
136 .I mode
137 引き数は、
138 .BR open (2)
139 と同じように、新しいセマフォに設定されるアクセス許可 (permission) を
140 指定する。許可設定はプロセスの umask でマスクされる
141 (許可ビットのシンボル定義は
142 .I <sys/stat.h>
143 のインクルードにより得られる)。
144 セマフォにアクセスしようとするユーザは、読み出し許可と書き込み許可の
145 両方を得る必要がある。
146 .\"O The
147 .\"O .I value
148 .\"O argument specifies the initial value for the new semaphore.
149 .\"O If
150 .\"O .B O_CREAT
151 .\"O is specified, and a semaphore with the given
152 .\"O .I name
153 .\"O already exists, then
154 .\"O .I mode
155 .\"O and
156 .\"O .I value
157 .\"O are ignored.
158 .I value
159 引き数は新しいセマフォの初期値を指定する。
160 .B O_CREAT
161 が指定され、指定した名前
162 .I name
163 のセマフォがすでに存在する場合、
164 .I mode
165
166 .I value
167 は無視される。
168 .\"O .SH RETURN VALUE
169 .SH 返り値
170 .\"O On success,
171 .\"O .BR sem_open ()
172 .\"O returns the address of the new semaphore;
173 .\"O this address is used when calling other semaphore-related functions.
174 .\"O On error,
175 .\"O .BR sem_open ()
176 .\"O returns
177 .\"O .BR SEM_FAILED ,
178 .\"O with
179 .\"O .I errno
180 .\"O set to indicate the error.
181 成功すると、
182 .BR sem_open ()
183 は新しいセマフォのアドレスを返す。
184 このアドレスは他のセマフォ関連の関数を呼び出す際に使用される。
185 エラーの場合、
186 .BR sem_open ()
187
188 .B SEM_FAILED
189 を返し、
190 .I errno
191 にエラーを示す値をセットする。
192 .\"O .SH ERRORS
193 .SH エラー
194 .TP
195 .B EACCES
196 .\"O The semaphore exists, but the caller does not have permission to
197 .\"O open it.
198 そのセマフォが存在するが、呼び出し元にはそのセマフォをオープンする
199 許可がない。
200 .TP
201 .B EEXIST
202 .\"O Both
203 .\"O .B O_CREAT
204 .\"O and
205 .\"O .B O_EXCL
206 .\"O were specified in
207 .\"O .IR oflag ,
208 .\"O but a semaphore with this
209 .\"O .I name
210 .\"O already exists.
211 .I oflag
212
213 .B O_CREAT
214
215 .B O_EXCL
216 の両方が指定されたが、
217 .I name
218 という名前のセマフォはすでに存在する。
219 .TP
220 .B EINVAL
221 .\"O .I value
222 .\"O was greater than
223 .\"O .BR SEM_VALUE_MAX .
224 .I value
225
226 .B SEM_VALUE_MAX
227 よりも大きい。
228 .TP
229 .B EINVAL
230 .\"O .I name
231 .\"O consists of just "/", followed by no other characters.
232 .I name
233 が "/" だけで構成され、その後ろに他の文字が続いていなかった。
234 .TP
235 .B EMFILE
236 .\"O The process already has the maximum number of files and open.
237 オープンされたファイル数がすでにそのプロセスにおける上限に達している。
238 .TP
239 .B ENAMETOOLONG
240 .\"O .I name
241 .\"O was too long.
242 .I name
243 が長すぎる。
244 .TP
245 .B ENFILE
246 .\"O The system limit on the total number of open files has been reached.
247 オープンされたファイル総数がシステム全体での上限に達している。
248 .TP
249 .B ENOENT
250 .\"O The
251 .\"O .B O_CREAT
252 .\"O flag was not specified in
253 .\"O .IR oflag
254 .\"O and no semaphore with this
255 .\"O .I name
256 .\"O exists;
257 .I oflag
258
259 .B O_CREAT
260 フラグが指定されておらず、
261 .I name
262 という名前のセマフォも存在しない。
263 .\"O or,
264 または、
265 .\" this error can occur if we have a name of the (nonportable) form
266 .\" /dir/name, and the directory /dev/shm/dir does not exist.
267 .\"O .B O_CREAT
268 .\"O was specified, but
269 .\"O .I name
270 .\"O wasn't well formed.
271 .B O_CREAT
272 が指定されたが、
273 .I name
274 が適切な形式ではなかった。
275 .TP
276 .B ENOMEM
277 .\"O Insufficient memory.
278 十分なメモリがない。
279 .\"O .SH CONFORMING TO
280 .SH 準拠
281 POSIX.1-2001.
282 .\"O .SH "SEE ALSO"
283 .SH 関連項目
284 .BR sem_close (3),
285 .BR sem_getvalue (3),
286 .BR sem_post (3),
287 .BR sem_unlink (3),
288 .BR sem_wait (3),
289 .BR sem_overview (7)