OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / 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)