OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / glibc-linuxthreads / draft / man3 / pthread_sigmask.3
1 .\"   Copyright (C) 1996-1999 Free Software Foundation, Inc.
2 .\"
3 .\"   Permission is granted to make and distribute verbatim copies of
4 .\" this manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\"   Permission is granted to copy and distribute modified versions of
8 .\" this manual under the conditions for verbatim copying, provided that
9 .\" the entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\"   Permission is granted to copy and distribute translations of this
13 .\" manual into another language, under the above conditions for modified
14 .\" versions, except that this permission notice may be stated in a
15 .\" translation approved by the Foundation.
16 .\"
17 .\" Copyright (C) 1996 Xavier Leroy.
18 .\"
19 .\" Japanese Version Copyright (C) 2002-2003 Suzuki Takashi
20 .\"         all rights reserved.
21 .\" Translated Tue Dec 31 20:02:27 JST 2002
22 .\"         by Suzuki Takashi.
23 .\"
24 .\"WORD:    handling of signals ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥ê¥ó¥°
25 .\"WORD:    signal mask         ¥·¥°¥Ê¥ë¥Þ¥¹¥¯
26 .\"WORD:    calling thread      ¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É
27 .\"WORD:    signal action       ¥·¥°¥Ê¥ë¥¢¥¯¥·¥ç¥ó
28 .\"WORD:    signal handler      ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é
29 .\"
30 .\"
31 .TH PTHREAD_SIGNAL 3 LinuxThreads
32
33
34 .\"O .SH NAME
35 .\"O pthread_sigmask, pthread_kill, sigwait \- handling of signals in threads
36 .SH "̾Á°"
37 pthread_sigmask, pthread_kill, sigwait \- ¥¹¥ì¥Ã¥ÉÆâ¤Ç¤Î¥·¥°¥Ê¥ë¥Ï¥ó¥É¥ê¥ó¥°
38
39 .\"O .SH SYNOPSIS
40 .SH "½ñ¼°"
41 .B #include <pthread.h>
42 .br
43 .B #include <signal.h>
44
45 .BI "int pthread_sigmask(int " how ", const sigset_t *" newmask ", sigset_t *" oldmask ");"
46
47 .BI "int pthread_kill(pthread_t " thread ", int " signo ");"
48
49 .BI "int sigwait(const sigset_t *" set ", int *" sig ");"
50
51 .\"O .SH DESCRIPTION
52 .SH "ÀâÌÀ"
53
54 .\"O .B "pthread_sigmask"
55 .\"O changes the signal mask for the calling thread as
56 .\"O described by the 
57 .\"O .I "how"
58 .\"O and 
59 .\"O .I "newmask"
60 .\"O arguments. If 
61 .\"O .I "oldmask"
62 .\"O is not
63 .\"O .BR "NULL" ,
64 .\"O the previous signal mask is stored in the location pointed to
65 .\"O by 
66 .\"O .IR "oldmask" .
67 .B "pthread_sigmask"
68 ¤Ï¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ò
69 °ú¿ô
70 .I "how"
71 ¤ª¤è¤Ó
72 .I "newmask"
73 ¤Ç»ØÄꤵ¤ì¤ë¤è¤¦¤ËÊѹ¹¤¹¤ë¡£
74 .I "oldmask"
75 ¤¬
76 .B "NULL"
77 ¤Ç¤Ê¤¤¤È¤­¤Ë¤Ï¡¢Ä¾Á°¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤¬
78 .I "oldmask"
79 ¤Ç»Ø¤·¼¨¤µ¤ì¤ëÎΰè¤Ë³ÊǼ¤µ¤ì¤ë¡£
80
81 .\"O The meaning of the 
82 .\"O .I "how"
83 .\"O and 
84 .\"O .I "newmask"
85 .\"O arguments is the same as for
86 .\"O .BR "sigprocmask" (2).
87 .\"O If 
88 .\"O .I "how"
89 .\"O is 
90 .\"O .BR "SIG_SETMASK" ,
91 .\"O the signal mask is set to
92 .\"O .IR "newmask" .
93 .\"O If 
94 .\"O .I "how"
95 .\"O is 
96 .\"O .BR "SIG_BLOCK" ,
97 .\"O the signals specified to 
98 .\"O .I "newmask"
99 .\"O are added to the current signal mask.  If 
100 .\"O .I "how"
101 .\"O is 
102 .\"O .BR "SIG_UNBLOCK" ,
103 .\"O the
104 .\"O signals specified to 
105 .\"O .I "newmask"
106 .\"O are removed from the current signal
107 .\"O mask.
108 °ú¿ô
109 .I "how"
110 ¤ª¤è¤Ó
111 .I "newmask"
112 ¤Î°ÕÌ£¤Ï
113 .BR "sigprocmask" (2)
114 ¤Î°ú¿ô¤Î°ÕÌ£¤ÈƱ¤¸¤Ç¤¢¤ë¡£
115 .I "how"
116 ¤¬
117 .B "SIG_SETMASK"
118 ¤Î¤È¤­¤Ë¤Ï¡¢
119 ¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤¬
120 .I "newmask"
121 ¤ËÀßÄꤵ¤ì¤ë¡£
122 .I "how"
123 ¤¬
124 .B "SIG_BLOCK"
125 ¤Î¤È¤­¤Ë¤Ï¡¢
126 .I "newmask"
127 ¤Ç»ØÄꤵ¤ì¤ë¥·¥°¥Ê¥ë¤¬¸½»þÅÀ¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ËÄɲ䵤ì¤ë¡£
128 .I "how"
129 ¤¬
130 .BR "SIG_UNBLOCK"
131 ¤Î¤È¤­¤Ë¤Ï¡¢
132 .I "newmask"
133 ¤Ç»ØÄꤵ¤ì¤ë¥·¥°¥Ê¥ë¤¬¸½»þÅÀ¤Î¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤«¤é¼è¤ê½ü¤«¤ì¤ë¡£
134
135 .\"O Recall that signal masks are set on a per-thread basis, but signal
136 .\"O actions and signal handlers, as set with 
137 .\"O .BR "sigaction" (2),
138 .\"O are shared
139 .\"O between all threads.
140 ¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤Ï¥¹¥ì¥Ã¥É¤´¤È¤ËÀßÄꤵ¤ì¤ë¤³¤È¤ò»×¤¤½Ð¤·¤Æ¤Û¤·¤¤¡£
141 ¤·¤«¤·
142 .BR "sigaction" (2)
143 ¤ÇÀßÄꤵ¤ì¤ë
144 ¥·¥°¥Ê¥ë¥¢¥¯¥·¥ç¥ó¤È¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ï¡¢
145 ¤¹¤Ù¤Æ¤Î¥¹¥ì¥Ã¥É¤Ç¶¦Ä̤Ǥ¢¤ë¡£
146
147 .\"O .B "pthread_kill"
148 .\"O send signal number 
149 .\"O .I "signo"
150 .\"O to the thread
151 .\"O .IR "thread" .
152 .\"O The signal is delivered and handled as described in
153 .\"O .BR "kill" (2).
154 .B "pthread_kill"
155 ¤Ï¥·¥°¥Ê¥ëÈÖ¹æ
156 .I "signo"
157 ¤Î¥·¥°¥Ê¥ë¤ò
158 ¥¹¥ì¥Ã¥É
159 .IR "thread"
160 ¤ËÁ÷¿®¤¹¤ë¡£
161 ¥·¥°¥Ê¥ë¤Ï
162 .BR "kill" (2)
163 ¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¤è¤¦¤ËÇÛÁ÷¤µ¤ì¥Ï¥ó¥É¥ë¤µ¤ì¤ë¡£
164
165 .\"O .B "sigwait"
166 .\"O suspends the calling thread until one of the signals
167 .\"O in 
168 .\"O .I "set"
169 .\"O is delivered to the calling thread. It then stores the number
170 .\"O of the signal received in the location pointed to by 
171 .\"O .I "sig"
172 .\"O and
173 .\"O returns. The signals in 
174 .\"O .I "set"
175 .\"O must be blocked and not ignored on
176 .\"O entrance to 
177 .\"O .BR "sigwait" .
178 .\"O If the delivered signal has a signal handler
179 .\"O function attached, that function is 
180 .\"O .I "not"
181 .\"O called.
182 .B "sigwait"
183 ¤Ï
184 .I "set"
185 ¤Ç»ØÄꤵ¤ì¤ë¥·¥°¥Ê¥ë¤Î¤¦¤Á¤¤¤º¤ì¤« 1 ¤Ä¤¬¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É¤Ë
186 ÇÛÁ÷¤µ¤ì¤ë¤Þ¤Ç¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É¤Î¼Â¹Ô¤òÄä»ß¤¹¤ë¡£
187 ¤½¤·¤Æ¼õ¿®¤·¤¿¥·¥°¥Ê¥ë¤Î¿ô¤ò
188 .I "sig"
189 ¤Ç»Ø¤·¼¨¤µ¤ì¤ëÎΰè¤Ë³ÊǼ¤·¤ÆÊ֤롣
190 .I "set"
191 ¤Ç»ØÄꤵ¤ì¤ë¥·¥°¥Ê¥ë¤Ï
192 .B "sigwait"
193 ¤ËÆþ¤ë¤È¤­¤Ë¥Ö¥í¥Ã¥¯¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢Ìµ»ë¤µ¤ì¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
194 ÇÛÁ÷¤µ¤ì¤¿¥·¥°¥Ê¥ë¤ËÂФ¹¤ë¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤Æ¤â¡¢
195 ¥Ï¥ó¥É¥é´Ø¿ô¤Ï¸Æ¤Ó½Ð¤µ¤ì
196 .I "¤Ê¤¤"
197 ¡£
198
199 .\"O .SH CANCELLATION
200 .SH "¼è¤ê¾Ã¤·"
201
202 .\"O .B "sigwait"
203 .\"O is a cancellation point.
204 .B "sigwait"
205 ¤Ï¼è¤ê¾Ã¤·¥Ý¥¤¥ó¥È¤Ç¤¢¤ë¡£
206
207 .\"O .SH "RETURN VALUE"
208 .SH "ÊÖ¤êÃÍ"
209
210 .\"O On success, 0 is returned. On failure, a non-zero error code is returned.
211 À®¸ù¤¹¤ë¤È¡¢0 ¤¬Ê֤롣
212 ¼ºÇԤξì¹ç¡¢Èó 0 ¤Î¥¨¥é¡¼¥³¡¼¥É¤¬Ê֤롣
213
214 .\"O .SH ERRORS
215 .SH "¥¨¥é¡¼"
216
217 .\"O The 
218 .\"O .B "pthread_sigmask"
219 .\"O function returns the following error codes
220 .\"O on error:
221 .\"O .RS
222 .\"O .TP
223 .\"O .B "EINVAL"
224 .\"O .I "how"
225 .\"O is not one of 
226 .\"O .BR "SIG_SETMASK" ,
227 .\"O .BR "SIG_BLOCK" ,
228 .\"O or 
229 .\"O .B "SIG_UNBLOCK"
230 ´Ø¿ô
231 .B "pthread_sigmask"
232 ¤Ï¥¨¥é¡¼¤Î¤È¤­¡¢¼¡¤Î¤è¤¦¤Ê¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤¹:
233 .RS
234 .TP
235 .B "EINVAL"
236 .I "how"
237 ¤¬
238 .B "SIG_SETMASK"
239 ¤ª¤è¤Ó
240 .B "SIG_BLOCK"
241 ¡¢
242 .B "SIG_UNBLOCK"
243 ¤Î¤¤¤º¤ì¤Ç¤â¤Ê¤¤¡£
244
245 .\"O .TP
246 .\"O .B "EFAULT"
247 .\"O .I "newmask"
248 .\"O or 
249 .\"O .I "oldmask"
250 .\"O point to invalid addresses
251 .\"O .RE
252 .TP
253 .B "EFAULT"
254 .I "newmask"
255 ¤Þ¤¿¤Ï
256 .I "oldmask"
257 ¤¬Ìµ¸ú¤Ê¥¢¥É¥ì¥¹¤ò»Ø¤·¤Æ¤¤¤ë¡£
258 .RE
259
260 .\"O The 
261 .\"O .B "pthread_kill"
262 .\"O function returns the following error codes
263 .\"O on error:
264 .\"O .RS
265 .\"O .TP
266 .\"O .B "EINVAL"
267 .\"O .I "signo"
268 .\"O is not a valid signal number
269 ´Ø¿ô
270 .B "pthread_kill"
271 ¤Ï¥¨¥é¡¼¤Î¤È¤­¡¢¼¡¤Î¤è¤¦¤Ê¥¨¥é¡¼¥³¡¼¥É¤òÊÖ¤¹:
272 .RS
273 .TP
274 .B "EINVAL"
275 .I "signo"
276 ¤ÏÍ­¸ú¤Ê¥·¥°¥Ê¥ëÈÖ¹æ¤Ç¤Ê¤¤¡£
277
278 .\"O .TP
279 .\"O .B "ESRCH"
280 .\"O the thread 
281 .\"O .I "thread"
282 .\"O does not exist (e.g. it has already terminated)
283 .\"O .RE
284 .TP
285 .B "ESRCH"
286 ¥¹¥ì¥Ã¥É
287 .I "thread"
288 ¤Ï¸ºß¤·¤Ê¤¤ (Î㤨¤Ð¡¢¤½¤Î¥¹¥ì¥Ã¥É¤Ï¤¹¤Ç¤Ë½ªÎ»¤·¤Æ¤¤¤ë) ¡£
289 .RE
290
291 .\"O The 
292 .\"O .B "sigwait"
293 .\"O function never returns an error.
294 ´Ø¿ô
295 .B "sigwait"
296 ¤¬¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤Ï¤Ê¤¤¡£
297
298 .\"O .SH AUTHOR
299 .SH "Ãø¼Ô"
300 Xavier Leroy <Xavier.Leroy@inria.fr>
301
302 .\"O .SH "SEE ALSO"
303 .SH "´ØÏ¢¹àÌÜ"
304 .BR "sigprocmask" (2),
305 .BR "kill" (2),
306 .BR "sigaction" (2),
307 .BR "sigsuspend" (2).
308
309 .\"O .SH NOTES
310 .SH "Ãí°Õ"
311
312 .\"O For 
313 .\"O .B "sigwait"
314 .\"O to work reliably, the signals being waited for must be
315 .\"O blocked in all threads, not only in the calling thread, since
316 .\"O otherwise the POSIX semantics for signal delivery do not guarantee
317 .\"O that it's the thread doing the 
318 .\"O .B "sigwait"
319 .\"O that will receive the signal.
320 .\"O The best way to achieve this is block those signals before any threads
321 .\"O are created, and never unblock them in the program other than by
322 .\"O calling 
323 .\"O .BR "sigwait" .
324 .B "sigwait"
325 ¤¬³Î¼Â¤Ëµ¡Ç½¤¹¤ë¤è¤¦¤Ë¡¢
326 ÇÛÁ÷¤òÂԤĥ·¥°¥Ê¥ë¤Ï¡¢¸Æ¤Ó½Ð¤·¥¹¥ì¥Ã¥É¤À¤±¤Ç¤Ê¤¯
327 ¤¹¤Ù¤Æ¤Î¥¹¥ì¥Ã¥É¤Ç¥Ö¥í¥Ã¥¯¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
328 ¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¡¢POSIX ¤Î¥·¥°¥Ê¥ëÇÛÁ÷µ¡¹½¤Ï
329 ¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¥¹¥ì¥Ã¥É¤¬
330 .B "sigwait"
331 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¤È¤Ê¤ë¤³¤È¤òÊݾڤ·¤Ê¤¤¡£
332 ¤³¤ì¤ò¼Â¸½¤¹¤ëºÇ¤â¤è¤¤ÊýË¡¤Ï¡¢
333 ¤É¤Î¥¹¥ì¥Ã¥É¤òÀ¸À®¤¹¤ë¤è¤ê¤âÁ°¤Ë¤½¤ì¤é¤Î¥·¥°¥Ê¥ë¤ò¥Ö¥í¥Ã¥¯¤·¡¢
334 ¥×¥í¥°¥é¥àÃæ¤Ç¤Ï
335 .B "sigwait"
336 ¤ò¸Æ¤Ó½Ð¤¹°Ê³°¡¢¥Ö¥í¥Ã¥¯¤ò²ò½ü¤·¤Ê¤¤¤³¤È¤Ç¤¢¤ë¡£
337
338 .\"O .SH BUGS
339 .SH "¥Ð¥°"
340
341 .\"O Signal handling in LinuxThreads departs significantly from the POSIX
342 .\"O standard. According to the standard, ``asynchronous'' (external)
343 .\"O signals are addressed to the whole process (the collection of all
344 .\"O threads), which then delivers them to one particular thread. The
345 .\"O thread that actually receives the signal is any thread that does
346 .\"O not currently block the signal.
347 LinuxThreads ¤Î¥·¥°¥Ê¥ë¥Ï¥ó¥É¥ê¥ó¥°¤Ï POSIX É¸½à¤È¤ÏÂ礭¤¯°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
348 POSIX É¸½à¤Ë¤è¤ë¤È¡¢¡ÖÈóƱ´ü¤Î¡× (³°Éô¤Î) ¥·¥°¥Ê¥ë¤Ï
349 ¥×¥í¥»¥¹Á´ÂΠ(¤¹¤Ù¤Æ¤Î¥¹¥ì¥Ã¥É¤Î½¸¤Þ¤ê) ¤ËÂФ·¤Æȯ¹Ô¤µ¤ì¡¢
350 ¤½¤Î¸åÆÃÄê¤Î 1 ¤Ä¤Î¥¹¥ì¥Ã¥É¤ËÇÛÁ÷¤µ¤ì¤ë¡£
351 ¼ÂºÝ¤Ë¥·¥°¥Ê¥ë¤ò¼õ¿®¤¹¤ë¥¹¥ì¥Ã¥É¤Ï
352 ¤½¤Î»þÅÀ¤Ç¥·¥°¥Ê¥ë¤ò¥Ö¥í¥Ã¥¯¤·¤Æ¤¤¤Ê¤¤¥¹¥ì¥Ã¥É¤Î¤¤¤º¤ì¤«¤È¤Ê¤ë¡£
353
354 .\"O In LinuxThreads, each thread is actually a kernel process with its own
355 .\"O PID, so external signals are always directed to one particular thread.
356 .\"O If, for instance, another thread is blocked in 
357 .\"O .B "sigwait"
358 .\"O on that
359 .\"O signal, it will not be restarted.
360 LinuxThreads ¤Ç¤Ï¡¢
361 ¤½¤ì¤¾¤ì¤Î¥¹¥ì¥Ã¥É¤¬¼ÂºÝ¤Ë¤Ï¸ÇÍ­¤Î PID ¤ò¤â¤Ä¥«¡¼¥Í¥ë¥×¥í¥»¥¹¤Ç¤¢¤ë¤¿¤á¡¢
362 ³°Éô¤Î¥·¥°¥Ê¥ë¤ÏÆÃÄê¤Î 1 ¤Ä¤Î¥¹¥ì¥Ã¥É¤ËľÀÜÇÛÁ÷¤µ¤ì¤ë¡£
363 Î㤨¤Ð¡¢¤â¤·Ê̤Υ¹¥ì¥Ã¥É¤¬
364 .B "sigwait"
365 ¤ò»È¤Ã¤Æ¤½¤Î¥·¥°¥Ê¥ë¤ò¥Ö¥í¥Ã¥¯¤·¤Æ¤â¡¢
366 ¤½¤Î¥¹¥ì¥Ã¥É¤¬ºÆ³«¤µ¤ì¤ë¤³¤È¤Ï¤Ê¤¤¡£
367
368 .\"O The LinuxThreads implementation of 
369 .\"O .B "sigwait"
370 .\"O installs dummy signal
371 .\"O handlers for the signals in 
372 .\"O .I "set"
373 .\"O for the duration of the wait. Since
374 .\"O signal handlers are shared between all threads, other threads must not
375 .\"O attach their own signal handlers to these signals, or alternatively
376 .\"O they should all block these signals (which is recommended anyway --
377 .\"O see the Notes section).
378 .B "sigwait"
379 ¤Î LinuxThreads ¤Î¼ÂÁõ¤Ç¤Ï¡¢
380 .B "sigwait"
381 ¤ÏÂÔ¤Á¤Î´ü´ÖÃæ¡¢
382 .I "set"
383 ¤Ë´Þ¤Þ¤ì¤ë¥·¥°¥Ê¥ë¤ËÂбþ¤¹¤ë¥À¥ß¡¼¤Î¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤òÅÐÏ¿¤¹¤ë¡£
384 ¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ï¤¹¤Ù¤Æ¤Î¥¹¥ì¥Ã¥É¤Ç¶¦Ä̤Ǥ¢¤ë¤¿¤á¡¢
385 ¾¤Î¥¹¥ì¥Ã¥É¤Ï¤³¤ì¤é¤Î¥·¥°¥Ê¥ë¤ËÂФ·¤ÆÆȼ«¤Î¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤òÅÐÏ¿¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
386 ¤¢¤ë¤¤¤Ï¤½¤ÎÂå¤ï¤ê¤Ë¡¢¤¹¤Ù¤Æ¤Î¥¹¥ì¥Ã¥É¤¬
387 ¤³¤ì¤é¤Î¥·¥°¥Ê¥ë¤ò¥Ö¥í¥Ã¥¯¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤
388 (¤³¤Î¤³¤È¤Ï¤È¤Ë¤«¤¯¿ä¾©¤µ¤ì¤Æ¤¤¤ë -- Ãí°Õ¤Î¥»¥¯¥·¥ç¥ó¤ò»²¾È¤Î¤³¤È) ¡£