OSDN Git Service

info/GNU_which: Add some explanations.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / sem_open.3
1 .\" Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
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 .\"*******************************************************************
26 .\"
27 .\" This file was generated with po4a. Translate the source file.
28 .\"
29 .\"*******************************************************************
30 .\"
31 .\" Japanese Version Copyright (c) 2006 Akihiro MOTOKI all rights reserved.
32 .\" Translated 2006-04-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
33 .\" Updated 2009-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.19
34 .\"
35 .TH SEM_OPEN 3 2020\-08\-13 Linux "Linux Programmer's Manual"
36 .SH 名前
37 sem_open \- 名前付きセマフォを初期化し、オープンする
38 .SH 書式
39 .nf
40 \fB#include <fcntl.h>\fP           /* For O_* constants */
41 \fB#include <sys/stat.h>\fP        /* For mode constants */
42 \fB#include <semaphore.h>\fP
43 .PP
44 \fBsem_t *sem_open(const char *\fP\fIname\fP\fB, int \fP\fIoflag\fP\fB);\fP
45 \fBsem_t *sem_open(const char *\fP\fIname\fP\fB, int \fP\fIoflag\fP\fB,\fP
46 \fB                mode_t \fP\fImode\fP\fB, unsigned int \fP\fIvalue\fP\fB);\fP
47 .fi
48 .PP
49 \fI\-pthread\fP とリンクする。
50 .SH 説明
51 \fBsem_open\fP()  は、新規の POSIX セマフォを作成するか、既存のセマフォのオープンを行う。 セマフォは \fIname\fP で識別される。
52 \fIname\fP の構成の詳細は \fBsem_overview\fP(7)  を参照。
53 .PP
54 .\" In reality the filesystem IDs are used on Linux.
55 \fIoflag\fP 引数には、 \fBsem_open\fP()  の動作を制御するフラグを指定する (oflag の値の定義は
56 \fI<fcntl.h>\fP のインクルードにより得られる)。 \fIoflag\fP に \fBO_CREAT\fP
57 が指定されると、まだ存在しない場合にはそのセマフォが作成される。 セマフォの所有者 (ユーザー ID)、グループ所有権 (グループ ID) には、
58 それぞれ呼び出し元プロセスの実効 UID、実効 GID が設定される。 \fIoflag\fP に \fBO_CREAT\fP と \fBO_EXCL\fP
59 の両方が指定された場合、指定された名前 \fIname\fP のセマフォがすでに存在するとエラーが返される。
60 .PP
61 \fIoflag\fP に \fBO_CREAT\fP を指定する場合、さらに引数が 2 つ必要である。 \fImode\fP 引数は、 \fBopen\fP(2)
62 と同じように、新しいセマフォに設定されるアクセス許可 (permission) を 指定する。許可設定はプロセスの umask でマスクされる
63 (許可ビットのシンボル定義は \fI<sys/stat.h>\fP のインクルードにより得られる)。
64 セマフォにアクセスしようとするユーザーは、読み出し許可と書き込み許可の 両方を得る必要がある。 \fIvalue\fP
65 引数は新しいセマフォの初期値を指定する。 \fBO_CREAT\fP が指定され、指定した名前 \fIname\fP のセマフォがすでに存在する場合、
66 \fImode\fP と \fIvalue\fP は無視される。
67 .SH 返り値
68 成功すると、 \fBsem_open\fP()  は新しいセマフォのアドレスを返す。 このアドレスは他のセマフォ関連の関数を呼び出す際に使用される。
69 エラーの場合、 \fBsem_open\fP()  は \fBSEM_FAILED\fP を返し、 \fIerrno\fP にエラーを示す値をセットする。
70 .SH エラー
71 .TP 
72 \fBEACCES\fP
73 そのセマフォが存在するが、呼び出し元にはそのセマフォをオープンする 許可がない。
74 .TP 
75 \fBEEXIST\fP
76 \fIoflag\fP に \fBO_CREAT\fP と \fBO_EXCL\fP の両方が指定されたが、 \fIname\fP という名前のセマフォはすでに存在する。
77 .TP 
78 \fBEINVAL\fP
79 \fIvalue\fP が \fBSEM_VALUE_MAX\fP よりも大きい。
80 .TP 
81 \fBEINVAL\fP
82 \fIname\fP が "/" だけで構成され、その後ろに他の文字が続いていなかった。
83 .TP 
84 \fBEMFILE\fP
85 オープンされたファイルディスクリプターの総数がプロセス単位の上限に達している。
86 .TP 
87 \fBENAMETOOLONG\fP
88 \fIname\fP が長すぎる。
89 .TP 
90 \fBENFILE\fP
91 オープンされたファイル総数がシステム全体での上限に達している。
92 .TP 
93 \fBENOENT\fP
94 .\" this error can occur if we have a name of the (nonportable) form
95 .\" /dir/name, and the directory /dev/shm/dir does not exist.
96 \fIoflag\fP に \fBO_CREAT\fP フラグが指定されておらず、 \fIname\fP という名前のセマフォも存在しない。 または、
97 \fBO_CREAT\fP が指定されたが、 \fIname\fP が適切な形式ではなかった。
98 .TP 
99 \fBENOMEM\fP
100 十分なメモリーがない。
101 .SH 属性
102 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。
103 .TS
104 allbox;
105 lb lb lb
106 l l l.
107 インターフェース        属性  値
108 T{
109 \fBsem_open\fP()
110 T}      Thread safety   MT\-Safe
111 .TE
112 .sp 1
113 .SH 準拠
114 POSIX.1\-2001, POSIX.1\-2008.
115 .SH 関連項目
116 \fBsem_close\fP(3), \fBsem_getvalue\fP(3), \fBsem_post\fP(3), \fBsem_unlink\fP(3),
117 \fBsem_wait\fP(3), \fBsem_overview\fP(7)
118 .SH この文書について
119 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
120 \%https://www.kernel.org/doc/man\-pages/ に書かれている。