2 .\" Hey Emacs! This file is -*- nroff -*- source.
4 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
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
30 .TH SEM_OPEN 3 2009-02-20 "Linux" "Linux Programmer's Manual"
33 .\"O sem_open \- initialize and open a named semaphore
34 sem_open \- 名前付きセマフォを初期化し、オープンする
38 .BR "#include <fcntl.h>" " /* For O_* constants */"
39 .BR "#include <sys/stat.h>" " /* For mode constants */"
40 .B #include <semaphore.h>
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 );
47 .\"O Link with \fI\-lrt\fP or \fI\-pthread\fP.
48 \fI\-lrt\fP または \fI\-pthread\fP でリンクする。
52 .\"O creates a new POSIX semaphore or opens an existing semaphore.
53 .\"O The semaphore is identified by
55 .\"O For details of the construction of
58 .\"O .BR sem_overview (7).
60 は、新規の POSIX セマフォを作成するか、既存のセマフォのオープンを行う。
71 .\"O argument specifies flags that control the operation of the call.
72 .\"O (Definitions of the flags values can be obtained by including
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.
95 が指定されると、まだ存在しない場合にはそのセマフォが作成される。
96 セマフォの所有者 (ユーザ ID)、グループ所有権 (グループ ID) には、
97 それぞれ呼び出し元プロセスの実効 UID、実効 GID が設定される。
98 .\" 実際は、Linux ではファイルシステム ID が使用される。
103 .\"O are specified in
105 .\"O then an error is returned if a semaphore with the given
115 のセマフォがすでに存在するとエラーが返される。
121 .\"O then two additional arguments must be supplied.
125 を指定する場合、さらに引き数が 2 つ必要である。
128 .\"O argument specifies the permissions to be placed on the new semaphore,
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.
139 と同じように、新しいセマフォに設定されるアクセス許可 (permission) を
140 指定する。許可設定はプロセスの umask でマスクされる
144 セマフォにアクセスしようとするユーザは、読み出し許可と書き込み許可の
148 .\"O argument specifies the initial value for the new semaphore.
151 .\"O is specified, and a semaphore with the given
153 .\"O already exists, then
159 引き数は新しいセマフォの初期値を指定する。
168 .\"O .SH RETURN VALUE
172 .\"O returns the address of the new semaphore;
173 .\"O this address is used when calling other semaphore-related functions.
177 .\"O .BR SEM_FAILED ,
180 .\"O set to indicate the error.
184 このアドレスは他のセマフォ関連の関数を呼び出す際に使用される。
196 .\"O The semaphore exists, but the caller does not have permission to
198 そのセマフォが存在するが、呼び出し元にはそのセマフォをオープンする
206 .\"O were specified in
208 .\"O but a semaphore with this
222 .\"O was greater than
223 .\"O .BR SEM_VALUE_MAX .
231 .\"O consists of just "/", followed by no other characters.
233 が "/" だけで構成され、その後ろに他の文字が続いていなかった。
236 .\"O The process already has the maximum number of files and open.
237 オープンされたファイル数がすでにそのプロセスにおける上限に達している。
246 .\"O The system limit on the total number of open files has been reached.
247 オープンされたファイル総数がシステム全体での上限に達している。
252 .\"O flag was not specified in
254 .\"O and no semaphore with this
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.
268 .\"O was specified, but
270 .\"O wasn't well formed.
277 .\"O Insufficient memory.
279 .\"O .SH CONFORMING TO
285 .BR sem_getvalue (3),