OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[linuxjm/LDP_man-pages.git] / draft / man2 / signalfd.2
1 .\" Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" starting from a version by Davide Libenzi <davidel@xmailserver.org>
3 .\"
4 .\" This program is free software; you can redistribute it and/or modify
5 .\" it under the terms of the GNU General Public License as published by
6 .\" the Free Software Foundation; either version 2 of the License, or
7 .\" (at your option) any later version.
8 .\"
9 .\" This program is distributed in the hope that it will be useful,
10 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 .\" GNU General Public License for more details.
13 .\"
14 .\" You should have received a copy of the GNU General Public License
15 .\" along with this program; if not, write to the Free Software
16 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 .\" MA  02111-1307  USA
18 .\"
19 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
20 .\"         all rights reserved.
21 .\" Translated 2008-04-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.79
22 .\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
23 .\" Updated 2009-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.18
24 .\" 
25 .TH SIGNALFD 2 2009-01-13 Linux "Linux Programmer's Manual"
26 .\"O .SH NAME
27 .SH Ì¾Á°
28 .\"O signalfd \- create a file descriptor for accepting signals
29 signalfd \- ¥·¥°¥Ê¥ë¼õ¤±ÉÕ¤±ÍѤΥե¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÀ¸À®¤¹¤ë
30 .\"O .SH SYNOPSIS
31 .SH ½ñ¼°
32 .B #include <sys/signalfd.h>
33 .sp
34 .BI "int signalfd(int " fd ", const sigset_t *" mask ", int " flags );
35 .\"O .SH DESCRIPTION
36 .SH ÀâÌÀ
37 .\"O .BR signalfd ()
38 .\"O creates a file descriptor that can be used to accept signals
39 .\"O targeted at the caller.
40 .\"O This provides an alternative to the use of a signal handler or
41 .\"O .BR sigwaitinfo (2),
42 .\"O and has the advantage that the file descriptor may be monitored by
43 .\"O .BR select (2),
44 .\"O .BR poll (2),
45 .\"O and
46 .\"O .BR epoll (7).
47 .BR signalfd ()
48 ¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ°¸¤Æ¤Î¥·¥°¥Ê¥ë¤ò¼õ¤±ÉÕ¤±¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤ë¥Õ¥¡¥¤¥ë
49 ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÀ¸À®¤¹¤ë¡£
50 ¤³¤ÎÊýË¡¤Ï¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ä
51 .BR sigwaitinfo (2)
52 ¤òÍѤ¤¤ëÊýË¡¤ÎÂå¤ï¤ê¤È¤Ê¤ë¤â¤Î¤Ç¤¢¤ê¡¢¤³¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò
53 .BR select (2),
54 .BR poll (2),
55 .BR epoll (7)
56 ¤Ç´Æ»ë¤Ç¤­¤ë¤È¤¤¤¦ÍøÅÀ¤¬¤¢¤ë¡£
57
58 .\"O The
59 .\"O .I mask
60 .\"O argument specifies the set of signals that the caller
61 .\"O wishes to accept via the file descriptor.
62 .\"O This argument is a signal set whose contents can be initialized
63 .\"O using the macros described in
64 .\"O .BR sigsetops (3).
65 .I mask
66 °ú¤­¿ô¤Ë¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤¬¤³¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿·Ðͳ¤Ç¼õ¤±ÉÕ¤±¤¿¤¤
67 ¥·¥°¥Ê¥ë½¸¹ç¤ò»ØÄꤹ¤ë¡£¤³¤Î°ú¤­¿ô¤Ç»ØÄꤹ¤ë¥·¥°¥Ê¥ë½¸¹ç¤ÎÆâÍƤϡ¢
68 .BR sigsetops (3)
69 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥Þ¥¯¥í¤ò»È¤Ã¤Æ½é´ü²½¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
70 .\"O Normally, the set of signals to be received via the
71 .\"O file descriptor should be blocked using
72 .\"O .BR sigprocmask (2),
73 .\"O to prevent the signals being handled according to their default
74 .\"O dispositions.
75 Ä̾¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿·Ðͳ¤Ç¼õ¿®¤¹¤ë¥·¥°¥Ê¥ë½¸¹ç¤Ï¡¢
76 ¤½¤Î¥·¥°¥Ê¥ë¤¬¥Ç¥Õ¥©¥ë¥È¤ÎÇÛÁ÷ÊýË¡¤Ë´ð¤¤¤Æ½èÍý¤µ¤ì¤ë¤Î¤òËɤ°¤¿¤á¤Ë¡¢
77 .BR sigprocmask (2)
78 ¤ò»È¤Ã¤Æ¥Ö¥í¥Ã¥¯¤·¤Æ¤ª¤¯¤Ù¤­¤Ç¤¢¤ë¡£
79 .\"O It is not possible to receive
80 .\"O .B SIGKILL
81 .\"O or
82 .\"O .B SIGSTOP
83 .\"O signals via a signalfd file descriptor;
84 .\"O these signals are silently ignored if specified in
85 .\"O .IR mask .
86 ¥·¥°¥Ê¥ë
87 .B SIGKILL
88 ¤È
89 .B SIGSTOP
90 ¤ò signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿·Ðͳ¤Ç¼õ¿®¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
91 ¤³¤ì¤é¤Î¥·¥°¥Ê¥ë¤¬
92 .I mask
93 ¤Ç»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤ÏÌۤäÆ̵»ë¤µ¤ì¤ë¡£
94
95 .\"O If the
96 .\"O .I fd
97 .\"O argument is \-1,
98 .\"O then the call creates a new file descriptor and associates the
99 .\"O signal set specified in
100 .\"O .I mask
101 .\"O with that descriptor.
102 .\"O If
103 .\"O .I fd
104 .\"O is not \-1,
105 .\"O then it must specify a valid existing signalfd file descriptor, and
106 .\"O .I mask
107 .\"O is used to replace the signal set associated with that descriptor.
108 .I fd
109 °ú¤­¿ô¤¬ \-1 ¤Î¾ì¹ç¡¢
110 .BR signalfd ()
111 ¤Ï¿·¤·¤¤¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÀ¸À®¤·¡¢
112 .I mask
113 ¤Ç»ØÄꤵ¤ì¤¿¥·¥°¥Ê¥ë½¸¹ç¤ò¤½¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë´ØÏ¢ÉÕ¤±¤ë¡£
114 .I fd
115 °ú¤­¿ô¤¬ \-1 °Ê³°¤Î¾ì¹ç¡¢
116 .I fd
117 ¤Ë¤ÏÍ­¸ú¤Ê´û¸¤Î signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
118 ¤½¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¥·¥°¥Ê¥ë½¸¹ç¤Ï
119 .I mask
120 ¤ò»È¤Ã¤ÆÃÖ¤­´¹¤¨¤é¤ì¤ë¡£
121
122 .\"O Starting with Linux 2.6.27, the following values may be bitwise ORed in
123 .\"O .IR flags
124 .\"O to change the behaviour of
125 .\"O .BR signalfd ():
126 Linux 2.6.27 °Ê¹ß¤Ç¤Ï¡¢
127 °Ê²¼¤ÎÃͤΤ¤¤¯¤Ä¤«¤ò¥Ó¥Ã¥Èñ°Ì¤ÎÏÀÍýÏ (OR) ¤Ç»ØÄꤹ¤ë¤³¤È¤Ç¡¢
128 .BR signalfd ()
129 ¤Î¿¶Éñ¤¤¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
130 .TP 14
131 .B SFD_NONBLOCK
132 .\"O Set the
133 .\"O .BR O_NONBLOCK
134 .\"O file status flag on the new open file description.
135 .\"O Using this flag saves extra calls to
136 .\"O .BR fcntl (2)
137 .\"O to achieve the same result.
138 ¿·¤·¤¯À¸À®¤µ¤ì¤ë¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò (open file description) ¤Î
139 .B O_NONBLOCK
140 ¥Õ¥¡¥¤¥ë¥¹¥Æ¡¼¥¿¥¹¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¡£
141 ¤³¤Î¥Õ¥é¥°¤ò»È¤¦¤³¤È¤Ç¡¢
142 .B O_NONBLOCK
143 ¤ò¥»¥Ã¥È¤¹¤ë¤¿¤á¤Ë
144 .BR fcntl (2)
145 ¤òÄɲäǸƤӽФ¹É¬Íפ¬¤Ê¤¯¤Ê¤ë¡£
146 .TP
147 .B SFD_CLOEXEC
148 .\"O Set the close-on-exec
149 .\"O .RB ( FD_CLOEXEC )
150 .\"O flag on the new file descriptor.
151 .\"O See the description of the
152 .\"O .B O_CLOEXEC
153 .\"O flag in
154 .\"O .BR open (2)
155 .\"O for reasons why this may be useful.
156 ¿·¤·¤¤¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ
157 close-on-exec
158 .RB ( FD_CLOEXEC )
159 ¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¡£
160 ¤³¤Î¥Õ¥é¥°¤¬Ìò¤ËΩ¤ÄÍýͳ¤Ë¤Ä¤¤¤Æ¤Ï¡¢
161 .BR open (2)
162 ¤Î
163 .B O_CLOEXEC
164 ¥Õ¥é¥°¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
165 .PP
166 .\"O In Linux up to version 2.6.26, the
167 .\"O .I flags
168 .\"O argument is unused, and must be specified as zero.
169 ¥Ð¡¼¥¸¥ç¥ó 2.6.26 °ÊÁ°¤Î Linux ¤Ç¤Ï¡¢
170 .I flags
171 °ú¤­¿ô¤Ï̤»ÈÍѤǤ¢¤ê¡¢0 ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
172
173 .\"O .BR signalfd ()
174 .\"O returns a file descriptor that supports the following operations:
175 .BR signalfd ()
176 ¤¬ÊÖ¤¹¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï°Ê²¼¤ÎÁàºî¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡£
177 .TP
178 .BR read (2)
179 .\"O If one or more of the signals specified in
180 .\"O .I mask
181 .\"O is pending for the process, then the buffer supplied to
182 .\"O .BR read (2)
183 .\"O is used to return one or more
184 .\"O .I signalfd_siginfo
185 .\"O structures (see below) that describe the signals.
186 .\"O The
187 .\"O .BR read (2)
188 .\"O returns information for as many signals as are pending and will
189 .\"O fit in the supplied buffer.
190 .\"O The buffer must be at least
191 .\"O .I "sizeof(struct signalfd_siginfo)"
192 .\"O bytes.
193 .\"O The return value of the
194 .\"O .BR read (2)
195 .\"O is the total number of bytes read.
196 .I mask
197 ¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ë¥·¥°¥Ê¥ë¤Î¤¦¤Á°ì¤Ä°Ê¾å¤¬¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ
198 ½èÍýÂÔ¤Á (pending) ¤Ç¤¢¤ì¤Ð¡¢¤½¤ì¤é¤Î¥·¥°¥Ê¥ë¤Î¾ðÊó¤¬
199 .BR read (2)
200 ¤ËÅϤµ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤ò»È¤Ã¤Æ¡¢
201 .I signalfd_siginfo
202 ¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¤ÆÊÖ¤µ¤ì¤ë¡£
203 .BR read (2)
204 ¤Ï¡¢¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ²Äǽ¤ÊÈϰϤǤǤ­¤ë¤À¤±Â¿¤¯¤Î½èÍýÂÔ¤Á¤Î¥·¥°¥Ê¥ë¤Ë
205 ¤Ä¤¤¤Æ¤Î¾ðÊó¤òÊÖ¤¹¡£
206 ¥Ð¥Ã¥Õ¥¡¤ÏºÇÄã¤Ç¤â
207 .I "sizeof(struct signalfd_siginfo)"
208 ¥Ð¥¤¥È¤ÎÂ礭¤µ¤¬¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
209 .BR read (2)
210 ¤ÎÊÖ¤êÃͤÏÆɤ߽Фµ¤ì¤¿¥È¡¼¥¿¥ë¤Î¥Ð¥¤¥È¿ô¤Ç¤¢¤ë¡£
211 .IP
212 .\"O As a consequence of the
213 .\"O .BR read (2),
214 .\"O the signals are consumed,
215 .\"O so that they are no longer pending for the process
216 .\"O (i.e., will not be caught by signal handlers,
217 .\"O and cannot be accepted using
218 .\"O .BR sigwaitinfo (2)).
219 .BR read (2)
220 ¤¬¹Ô¤ï¤ì¤¿·ë²Ì¡¢¥·¥°¥Ê¥ë¤Ï¾ÃÈñ¤µ¤ì¡¢
221 ¤³¤ì¤é¤Î¥·¥°¥Ê¥ë¤Ï¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ¤Ï½èÍýÂÔ¤Á¤Ç¤Ï¤Ê¤¯¤Ê¤ë
222 (¤Ä¤Þ¤ê¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ÇÊ᪤µ¤ì¤ë¤³¤È¤â¤Ê¤¯¡¢
223 .BR sigwaitinfo (2)
224 ¤ò»È¤Ã¤Æ¼õ¤±¼è¤ë¤³¤È¤â¤Ç¤­¤Ê¤¯¤Ê¤ë)¡£
225 .IP
226 .\"O If none of the signals in
227 .\"O .I mask
228 .\"O is pending for the process, then the
229 .\"O .BR read (2)
230 .\"O either blocks until one of the signals in
231 .\"O .I mask
232 .\"O is generated for the process,
233 .\"O or fails with the error
234 .\"O .B EAGAIN
235 .\"O if the file descriptor has been made nonblocking.
236 .I mask
237 ¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ë¥·¥°¥Ê¥ë¤¬¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ°ì¤Ä¤â½èÍýÂÔ¤Á¤Ç¤Ê¤±¤ì¤Ð¡¢
238 .BR read (2)
239 ¤Ï¡¢
240 .I mask
241 ¤Ç»ØÄꤵ¤ì¤¿¥·¥°¥Ê¥ë¤Î¤¦¤Á¤¤¤º¤ì¤«°ì¤Ä¤¬¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤ÆȯÀ¸¤¹¤ë¤Þ¤Ç
242 Ää»ß (block) ¤¹¤ë¡¢¤â¤·¤¯¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ÈóÄä»ß (nonblocking)
243 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¨¥é¡¼
244 .B EAGAIN
245 ¤Ç¼ºÇÔ¤¹¤ë¡£
246 .TP
247 .\"O .BR poll "(2), " select "(2) (and similar)"
248 .BR poll "(2), " select "(2) (¤ÈƱÍͤÎÁàºî)"
249 .\"O The file descriptor is readable
250 .\"O (the
251 .\"O .BR select (2)
252 .\"O .I readfds
253 .\"O argument; the
254 .\"O .BR poll (2)
255 .\"O .B POLLIN
256 .\"O flag)
257 .\"O if one or more of the signals in
258 .\"O .I mask
259 .\"O is pending for the process.
260 .I mask
261 ¤Ë»ØÄꤵ¤ì¤¿¥·¥°¥Ê¥ë¤Î¤¦¤Á°ì¤Ä°Ê¾å¤¬¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ½èÍýÂÔ¤Á¤Ç¤¢¤ì¤Ð¡¢
262 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÏÆɤ߽Ф·²Äǽ¤È¤Ê¤ë
263 .RB ( select (2)
264 ¤Î
265 .I readfds
266 °ú¤­¿ô¤ä
267 .BR poll (2)
268 ¤Î
269 .B POLLIN
270 ¥Õ¥é¥°)¡£
271 .IP
272 .\"O The signalfd file descriptor also supports the other file-descriptor
273 .\"O multiplexing APIs:
274 .\"O .BR pselect (2),
275 .\"O .BR ppoll (2),
276 .\"O and
277 .\"O .BR epoll (7).
278 signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¤³¤ì°Ê³°¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
279 ¿½Å API ¤Ç¤¢¤ë
280 .BR pselect (2),
281 .BR ppoll (2),
282 .BR epoll (7)
283 ¤â¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡£
284 .TP
285 .BR close (2)
286 .\"O When the file descriptor is no longer required it should be closed.
287 .\"O When all file descriptors associated with the same signalfd object
288 .\"O have been closed, the resources for object are freed by the kernel.
289 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¤½¤ì°Ê¹ß¤ÏɬÍפʤ¯¤Ê¤Ã¤¿ºÝ¤Ë¤Ï¡¢¥¯¥í¡¼¥º¤¹¤Ù¤­¤Ç¤¢¤ë¡£
290 Ʊ¤¸ signalfd ¥ª¥Ö¥¸¥§¥¯¥È¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Á´¤Æ
291 ¥¯¥í¡¼¥º¤µ¤ì¤ë¤È¡¢¤½¤Î¥ª¥Ö¥¸¥§¥¯¥ÈÍѤλñ¸»¤¬¥«¡¼¥Í¥ë¤Ë¤è¤ê²òÊü¤µ¤ì¤ë¡£
292 .\"O .SS The signalfd_siginfo structure
293 .SS signalfd_siginfo ¹½Â¤ÂÎ
294 .\"O The format of the
295 .\"O .I signalfd_siginfo
296 .\"O structure(s) returned by
297 .\"O .BR read (2)s
298 .\"O from a signalfd file descriptor is as follows:
299 signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤«¤é¤Î
300 .BR read (2)
301 ¤ÇÊÖ¤µ¤ì¤ë
302 .I signalfd_siginfo
303 ¹½Â¤ÂΤΥե©¡¼¥Þ¥Ã¥È¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
304 .in +4n
305 .nf
306
307 struct signalfd_siginfo {
308 .\"O     uint32_t ssi_signo;   /* Signal number */
309 .\"O     int32_t  ssi_errno;   /* Error number (unused) */
310 .\"O     int32_t  ssi_code;    /* Signal code */
311 .\"O     uint32_t ssi_pid;     /* PID of sender */
312 .\"O     uint32_t ssi_uid;     /* Real UID of sender */
313 .\"O     int32_t  ssi_fd;      /* File descriptor (SIGIO) */
314 .\"O     uint32_t ssi_tid;     /* Kernel timer ID (POSIX timers)
315 .\"O     uint32_t ssi_band;    /* Band event (SIGIO) */
316 .\"O     uint32_t ssi_overrun; /* POSIX timer overrun count */
317 .\"O     uint32_t ssi_trapno;  /* Trap number that caused signal */
318 .\"O .\" ssi_trapno is unused on most arches
319 .\"O     int32_t  ssi_status;  /* Exit status or signal (SIGCHLD) */
320 .\"O     int32_t  ssi_int;     /* Integer sent by sigqueue(3) */
321 .\"O     uint64_t ssi_ptr;     /* Pointer sent by sigqueue(3) */
322 .\"O     uint64_t ssi_utime;   /* User CPU time consumed (SIGCHLD) */
323 .\"O     uint64_t ssi_stime;   /* System CPU time consumed (SIGCHLD) */
324 .\"O     uint64_t ssi_addr;    /* Address that generated signal
325 .\"O                              (for hardware-generated signals) */
326 .\"O     uint8_t  pad[\fIX\fP];      /* Pad size to 128 bytes (allow for
327 .\"O                               additional fields in the future) */
328 struct signalfd_siginfo {
329     uint32_t ssi_signo;   /* ¥·¥°¥Ê¥ëÈÖ¹æ */
330     int32_t  ssi_errno;   /* ¥¨¥é¡¼ÈÖ¹æ (̤»ÈÍÑ) */
331     int32_t  ssi_code;    /* ¥·¥°¥Ê¥ë¥³¡¼¥É */
332     uint32_t ssi_pid;     /* Á÷¿®¸µ¤Î PID */
333     uint32_t ssi_uid;     /* Á÷¿®¸µ¤Î¼Â UID */
334     int32_t  ssi_fd;      /* ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿ (SIGIO) */
335     uint32_t ssi_tid;     /* ¥«¡¼¥Í¥ë¥¿¥¤¥Þ ID (POSIX ¥¿¥¤¥Þ)
336     uint32_t ssi_band;    /* Band ¥¤¥Ù¥ó¥È (SIGIO) */
337     uint32_t ssi_overrun; /* POSIX ¥¿¥¤¥Þ¤Î¥ª¡¼¥Ð¡¼¥é¥ó²ó¿ô */
338     uint32_t ssi_trapno;  /* ¥·¥°¥Ê¥ë¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥È¥é¥Ã¥×ÈÖ¹æ */
339 .\" ¤Û¤È¤ó¤É¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç ssi_trapno ¤Ï̤»ÈÍÑ
340     int32_t  ssi_status;  /* ½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤«¥·¥°¥Ê¥ë (SIGCHLD) */
341     int32_t  ssi_int;     /* sigqueue(3) ¤«¤éÁ÷¤é¤ì¤¿À°¿ô */
342     uint64_t ssi_ptr;     /* sigqueue(3) ¤«¤éÁ÷¤é¤ì¤¿¥Ý¥¤¥ó¥¿ */
343     uint64_t ssi_utime;   /* ¾ÃÈñ¤·¤¿¥æ¡¼¥¶ CPU »þ´Ö (SIGCHLD) */
344     uint64_t ssi_stime;   /* ¾ÃÈñ¤·¤¿¥·¥¹¥Æ¥à CPU »þ´Ö (SIGCHLD) */
345     uint64_t ssi_addr;    /* ¥·¥°¥Ê¥ë¤òÀ¸À®¤·¤¿¥¢¥É¥ì¥¹
346                              (¥Ï¡¼¥É¥¦¥§¥¢¤¬À¸À®¤·¤¿¥·¥°¥Ê¥ë¤Î¾ì¹ç) */
347     uint8_t  pad[\fIX\fP];      /* pad ¤ÎÂ礭¤µ¤Ï 128 ¥Ð¥¤¥È
348                              (¾­Íè¤Î¥Õ¥£¡¼¥ë¥ÉÄɲÃÍѤξì½ê¤Î³ÎÊÝ) */
349 };
350
351 .fi
352 .in
353 .\"O Each of the fields in this structure
354 .\"O is analogous to the similarly named field in the
355 .\"O .I siginfo_t
356 .\"O structure.
357 .\"O The
358 .\"O .I siginfo_t
359 .\"O structure is described in
360 .\"O .BR sigaction (2).
361 .I signalfd_siginfo
362 ¹½Â¤ÂΤγƥե£¡¼¥ë¥É¤Ï¡¢
363 .I siginfo_t
364 ¹½Â¤ÂΤÎƱ¤¸¤è¤¦¤Ê̾Á°¤Î¥Õ¥£¡¼¥ë¥É¤ÈƱÍͤǤ¢¤ë¡£
365 .I siginfo_t
366 ¹½Â¤ÂΤˤĤ¤¤Æ¤Ï
367 .BR sigaction (2)
368 ¤ËÀâÌÀ¤¬¤¢¤ë¡£
369 .\"O Not all fields in the returned
370 .\"O .I signalfd_siginfo
371 .\"O structure will be valid for a specific signal;
372 .\"O the set of valid fields can be determined from the value returned in the
373 .\"O .I ssi_code
374 .\"O field.
375 .\"O This field is the analog of the
376 .\"O .I siginfo_t
377 .\"O .I si_code
378 .\"O field; see
379 .\"O .BR sigaction (2)
380 .\"O for details.
381 ÊÖ¤µ¤ì¤¿
382 .I signalfd_siginfo
383 ¹½Â¤ÂΤÎÁ´¤Æ¤Î¥Õ¥£¡¼¥ë¥É¤¬¤¢¤ë¥·¥°¥Ê¥ë¤ËÂФ·¤ÆÍ­¸ú¤Ê¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
384 ¤É¤Î¥Õ¥£¡¼¥ë¥É¤¬Í­¸ú¤«¤Ï¡¢
385 .I ssi_code
386 ¥Õ¥£¡¼¥ë¥É¤ÇÊÖ¤µ¤ì¤ëÃͤ«¤éȽÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
387 ¤³¤Î¥Õ¥£¡¼¥ë¥É¤Ï
388 .I siginfo_t
389 ¤Î
390 .I si_code
391 ¥Õ¥£¡¼¥ë¥É¤ÈƱÍͤǤ¢¤ë¡£¾ÜºÙ¤Ï
392 .BR sigaction (2)
393 ¤ò»²¾È¡£
394 .\"O .SS fork(2) semantics
395 .SS fork(2) ¤Ç¤Î°·¤¤
396 .\"O After a
397 .\"O .BR fork (2),
398 .\"O the child inherits a copy of the signalfd file descriptor.
399 .\"O A
400 .\"O .BR read (2)
401 .\"O from the file descriptor in the child will return information
402 .\"O about signals queued to the child.
403 .BR fork (2)
404 ¤¬¹Ô¤ï¤ì¤ë¤È¡¢»Ò¥×¥í¥»¥¹¤Ï signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¥³¥Ô¡¼¤ò
405 ·Ñ¾µ¤¹¤ë¡£
406 »Ò¥×¥í¥»¥¹¤Ç¤³¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤«¤é
407 .BR read (2)
408 ¤ò¹Ô¤¦¤È¡¢»Ò¥×¥í¥»¥¹¤ËÂФ¹¤ë¥­¥å¡¼¤ËÆþ¤Ã¤Æ¤¤¤ë¥·¥°¥Ê¥ë¤Ë´Ø¤¹¤ë
409 ¾ðÊó¤¬ÊÖ¤µ¤ì¤ë¡£
410 .\"O .SS execve(2) semantics
411 .SS execve(2) ¤Ç¤Î°·¤¤
412 .\"O Just like any other file descriptor,
413 .\"O a signalfd file descriptor remains open across an
414 .\"O .BR execve (2),
415 .\"O unless it has been marked for close-on-exec (see
416 .\"O .BR fcntl (2)).
417 .\"O Any signals that were available for reading before the
418 .\"O .BR execve (2)
419 .\"O remain available to the newly loaded program.
420 .\"O (This is analogous to traditional signal semantics,
421 .\"O where a blocked signal that is pending remains pending across an
422 .\"O .BR execve (2).)
423 ¾¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÈÁ´¤¯Æ±Íͤˡ¢
424 signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤â
425 .BR execve (2)
426 ¤ÎÁ°¸å¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤¿¤Þ¤Þ¤È¤Ê¤ë¡£Ã¢¤·¡¢¤½¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë
427 close-on-exec ¤Î¥Þ¡¼¥¯
428 .RB ( fcntl (2)
429 »²¾È) ¤¬ÉÕ¤¤¤Æ¤¤¤ë¾ì¹ç¤Ï¥¯¥í¡¼¥º¤µ¤ì¤ë¡£
430 .BR execve (2)
431 ¤ÎÁ°¤ËÆɤ߽Ф·²Äǽ¤È¤Ê¤Ã¤Æ¤¤¤¿Á´¤Æ¤Î¥·¥°¥Ê¥ë¤Ï¿·¤·¤¯µ¯Æ°¤µ¤ì¤¿¥×¥í¥°¥é¥à
432 ¤Ç¤â°ú¤­Â³¤­Æɤ߽Ф·²Äǽ¤Ç¤¢¤ë
433 (¤³¤ì¤ÏÅÁÅýŪ¤Ê¥·¥°¥Ê¥ë¤Î°·¤¤¤ÈƱ¤¸¤Ç¤¢¤ê¡¢
434 ½èÍýÂÔ¤Á¤Î¥Ö¥í¥Ã¥¯¤µ¤ì¤¿¥·¥°¥Ê¥ë¤Ï
435 .BR execve (2)
436 ¤ÎÁ°¸å¤Ç½èÍýÂÔ¤Á¤Î¤Þ¤Þ¤È¤Ê¤ë)¡£
437 .\"O .SS Thread semantics
438 .SS ¥¹¥ì¥Ã¥É¤Ç¤Î°·¤¤
439 .\"O The semantics of signalfd file descriptors in a multithreaded program
440 .\"O mirror the standard semantics for signals.
441 .\"O In other words,
442 .\"O when a thread reads from a signalfd file descriptor,
443 .\"O it will read the signals that are directed to the thread
444 .\"O itself and the signals that are directed to the process
445 .\"O (i.e., the entire thread group).
446 .\"O (A thread will not be able to read signals that are directed
447 .\"O to other threads in the process.)
448 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥°¥é¥à¤Ë¤ª¤±¤ë signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î°·¤¤¤Ï
449 ¥·¥°¥Ê¥ë¤Îɸ½àŪ¤Ê°·¤¤¤ÈÁ´¤¯Æ±¤¸¤Ç¤¢¤ë¡£
450 ¸À¤¤´¹¤¨¤ë¤È¡¢¤¢¤ë¥¹¥ì¥Ã¥É¤¬ signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤«¤é
451 Æɤ߽Ф·¤ò¹Ô¤¦¤È¡¢¤½¤Î¥¹¥ì¥Ã¥É¼«¿È°¸¤Æ¤Î¥·¥°¥Ê¥ë¤È¥×¥í¥»¥¹ (¤¹¤Ê¤ï¤Á
452 ¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×Á´ÂÎ) °¸¤Æ¤Î¥·¥°¥Ê¥ë¤¬Æɤ߽Фµ¤ì¤ë¡£
453 (¥¹¥ì¥Ã¥É¤ÏƱ¤¸¥×¥í¥»¥¹¤Î¾¤Î¥¹¥ì¥Ã¥É°¸¤Æ¤Î¥·¥°¥Ê¥ë¤òÆɤ߽Ф¹¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£)
454 .\"O .SH "RETURN VALUE"
455 .SH ÊÖ¤êÃÍ
456 .\"O On success,
457 .\"O .BR signalfd ()
458 .\"O returns a signalfd file descriptor;
459 .\"O this is either a new file descriptor (if
460 .\"O .I fd
461 .\"O was \-1), or
462 .\"O .I fd
463 .\"O if
464 .\"O .I fd
465 .\"O was a valid signalfd file descriptor.
466 .\"O On error, \-1 is returned and
467 .\"O .I errno
468 .\"O is set to indicate the error.
469 À®¸ù¤¹¤ë¤È¡¢
470 .BR signalfd ()
471 ¤Ï signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
472 ÊÖ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢
473 .IR fd
474 ¤¬ \-1 ¤Î¾ì¹ç¤Ï¿·µ¬¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ê¡¢
475 .I fd
476 ¤¬Í­¸ú¤Ê signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤À¤Ã¤¿¾ì¹ç¤Ï
477 .I fd
478 ¼«¿È¤Ç¤¢¤ë¡£
479 ¥¨¥é¡¼¤Î¾ì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
480 .I errno
481 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
482 .\"O .SH ERRORS
483 .SH ¥¨¥é¡¼
484 .TP
485 .B EBADF
486 .\"O The
487 .\"O .I fd
488 .\"O file descriptor is not a valid file descriptor.
489 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
490 .I fd
491 ¤¬Í­¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
492 .TP
493 .B EINVAL
494 .\"O .I fd
495 .\"O is not a valid signalfd file descriptor.
496 .I fd
497 ¤¬Í­¸ú¤Ê signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ï¤Ê¤¤¡£
498 .\" or, the
499 .\" .I sizemask
500 .\" argument is not equal to
501 .\" .IR sizeof(sigset_t) ;
502 .TP
503 .B EINVAL
504 .\"O .I flags
505 .\"O is invalid;
506 .\"O or, in Linux 2.6.26 or earlier,
507 .\"O .I flags
508 .\"O is nonzero.
509 .I flags
510 ¤¬Ìµ¸ú¡£
511 Linux 2.6.26 °ÊÁ°¤Ç¤Ï¡¢
512 .I flags
513 ¤¬ 0 °Ê³°¤ÎÃÍ¡£
514 .TP
515 .B EMFILE
516 .\"O The per-process limit of open file descriptors has been reached.
517 ¥ª¡¼¥×¥óºÑ¤ß¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¿ô¤¬¥×¥í¥»¥¹¤¢¤¿¤ê¤Î¾å¸Â¤Ë
518 㤷¤Æ¤¤¤¿¡£
519 .TP
520 .B ENFILE
521 .\"O The system-wide limit on the total number of open files has been
522 .\"O reached.
523 ¥ª¡¼¥×¥óºÑ¤ß¤Î¥Õ¥¡¥¤¥ëÁí¿ô¤¬¥·¥¹¥Æ¥àÁ´ÂΤξå¸Â¤Ë㤷¤Æ¤¤¤¿¡£
524 .TP
525 .B ENODEV
526 .\"O Could not mount (internal) anonymous inode device.
527 (¥«¡¼¥Í¥ëÆâ¤Î) ÌµÌ¾ inode ¥Ç¥Ð¥¤¥¹¤ò¥Þ¥¦¥ó¥È¤Ç¤­¤Ê¤«¤Ã¤¿¡£
528 .TP
529 .B ENOMEM
530 .\"O There was insufficient memory to create a new signalfd file descriptor.
531 ¿·¤·¤¤ signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÀ¸À®¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤«¤Ã¤¿¡£
532 .\"O .SH VERSIONS
533 .SH ¥Ð¡¼¥¸¥ç¥ó
534 .\"O .BR signalfd ()
535 .\"O is available on Linux since kernel 2.6.22.
536 .\"O Working support is provided in glibc since version 2.8.
537 .BR signalfd ()
538 ¤Ï¥«¡¼¥Í¥ë 2.6.22 °Ê¹ß¤Î Linux ¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
539 Àµ¤·¤¯Æ°ºî¤¹¤ë glibc Â¦¤Î¥µ¥Ý¡¼¥È¤Ï¥Ð¡¼¥¸¥ç¥ó 2.8 °Ê¹ß¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
540 .\" signalfd() is in glibc 2.7, but reportedly does not build
541 .\"O The
542 .\"O .BR signalfd4 ()
543 .\"O system call (see NOTES) is available on Linux since kernel 2.6.27.
544 .BR signalfd4 ()
545 ¥·¥¹¥Æ¥à¥³¡¼¥ë (¡ÖÃí°Õ¡×»²¾È) ¤Ï
546 ¥«¡¼¥Í¥ë 2.6.27 °Ê¹ß¤Î Linux ¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
547 .\"O .SH CONFORMING TO
548 .SH ½àµò
549 .\"O .BR signalfd ()
550 .\"O and
551 .\"O .BR signalfd4 ()
552 .\"O are Linux-specific.
553 .BR signalfd ()
554 ¤È
555 .BR signalfd4 ()
556 ¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£
557 .\"O .SH NOTES
558 .SH Ãí°Õ
559 .\"O The underlying Linux system call requires an additional argument,
560 .\"O .IR "size_t sizemask" ,
561 .\"O which specifies the size of the
562 .\"O .I mask
563 .\"O argument.
564 .\"O The glibc
565 .\"O .BR signalfd ()
566 .\"O wrapper function does not include this argument,
567 .\"O since it provides the required value for the underlying system call.
568 ¼ÂºÝ¤Î Linux ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ç¤Ï
569 .I "size_t sizemask"
570 ¤È¤¤¤¦°ú¤­¿ô¤¬ÄɲäÇɬÍפǤ¢¤ë¡£¤³¤Î°ú¤­¿ô¤Ç
571 .I mask
572 ¤Î¥µ¥¤¥º¤ò»ØÄꤹ¤ë¡£
573 glibc ¤Î
574 .BR signalfd ()
575 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ë¤Ï¤³¤Î°ú¤­¿ô¤Ï´Þ¤Þ¤ì¤º¡¢
576 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬É¬ÍפÊÃͤò·×»»¤·¤ÆÆâÉô¤Ç¸Æ¤Ó½Ð¤¹¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÄ󶡤¹¤ë¡£
577
578 .\"O A process can create multiple signalfd file descriptors.
579 .\"O This makes it possible to accept different signals
580 .\"O on different file descriptors.
581 .\"O (This may be useful if monitoring the file descriptors using
582 .\"O .BR select (2),
583 .\"O .BR poll (2),
584 .\"O or
585 .\"O .BR epoll (7):
586 .\"O the arrival of different signals will make different descriptors ready.)
587 .\"O If a signal appears in the
588 .\"O .I mask
589 .\"O of more than one of the file descriptors, then occurrences
590 .\"O of that signal can be read (once) from any one of the descriptors.
591 °ì¤Ä¤Î¥×¥í¥»¥¹¤ÏÊ£¿ô¤Î signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÀ¸À®¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
592 ¤³¤ì¤Ë¤è¤ê¡¢°Û¤Ê¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç°Û¤Ê¤ë¥·¥°¥Ê¥ë¤ò¼õ¤±¼è¤ë¤³¤È¤¬
593 ¤Ç¤­¤ë (¤³¤Îµ¡Ç½¤Ï
594 .BR select (2),
595 .BR poll (2),
596 .BR epoll (7)
597 ¤ò»È¤Ã¤Æ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò´Æ»ë¤¹¤ë¾ì¹ç¤ËÍ­ÍѤ«¤â¤·¤ì¤Ê¤¤¡£
598 °Û¤Ê¤ë¥·¥°¥Ê¥ë¤¬ÅþÃ夹¤ë¤È¡¢°Û¤Ê¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ÍøÍѲÄǽ¤Ë
599 ¤Ê¤ë¤«¤é¤À)¡£
600 °ì¤Ä¤Î¥·¥°¥Ê¥ë¤¬Æó¤Ä°Ê¾å¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î
601 .I mask
602 ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¤½¤Î¥·¥°¥Ê¥ë¤ÎȯÀ¸¤Ï¤½¤Î¥·¥°¥Ê¥ë¤ò
603 .I mask
604 ¤Ë´Þ¤à¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¦¤Á¤¤¤º¤ì¤«°ì¤Ä¤«¤éÆɤ߽Ф¹¤³¤È¤¬¤Ç¤­¤ë¡£
605 .\"O .SS Underlying Linux system calls
606 .SH ²¼Áؤˤ¢¤ë Linux ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë
607 .\"O There are two underlying Linux system calls:
608 .\"O .BR signalfd ()
609 .\"O and the more recent
610 .\"O .BR signalfd4 ().
611 .\"O The former system call does not implement a
612 .\"O .I flags
613 .\"O argument.
614 .\"O The latter system call implements the
615 .\"O .I flags
616 .\"O values described above.
617 ²¼Áؤˤ¢¤ë Linux ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÆó¼ïÎढ¤ê¡¢
618 .BR signalfd ()
619 ¤È¡¢¤â¤Ã¤È¿·¤·¤¤
620 .BR signalfd4 ()
621 ¤Ç¤¢¤ë¡£
622 .BR signalfd ()
623 ¤Ï
624 .I flags
625 °ú¤­¿ô¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤¡£
626 .BR signalfd4 ()
627 ¤Ç¤Ï¾åµ­¤ÎÃͤÎ
628 .I flags
629 ¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¡£
630 .\"O Starting with glibc 2.9, the
631 .\"O .BR signalfd ()
632 .\"O wrapper function will use
633 .\"O .BR signalfd4 ()
634 .\"O where it is available.
635 glibc 2.9 °Ê¹ß¤Ç¤Ï¡¢
636 .BR signalfd ()
637 ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¡¢
638 .BR signalfd4 ()
639 ¤¬ÍøÍѲÄǽ¤Ç¤¢¤ì¤Ð¡¢¤³¤ì¤ò»ÈÍѤ¹¤ë¡£
640 .\"O .SH BUGS
641 .SH ¥Ð¥°
642 .\"O In kernels before 2.6.25, the
643 .\"O .I ssi_ptr
644 .\"O and
645 .\"O .I ssi_int
646 .\"O fields are not filled in with the data accompanying a signal sent by
647 .\"O .BR sigqueue (3).
648 ¥«¡¼¥Í¥ë 2.6.25 ¤è¤êÁ°¤Ç¤Ï¡¢
649 .BR sigqueue (3)
650 ¤Ë¤è¤êÁ÷¿®¤µ¤ì¤¿¥·¥°¥Ê¥ë¤È°ì½ï¤ËÅϤµ¤ì¤ë¥Ç¡¼¥¿¤Ç¤Ï¡¢¥Õ¥£¡¼¥ë¥É
651 .I ssi_ptr
652 ¤È
653 .I ssi_int
654 ¤ÏÀßÄꤵ¤ì¤Ê¤¤¡£
655 .\" The fix also was put into 2.6.24.5
656 .\"O .SH EXAMPLE
657 .SH Îã
658 .\"O The program below accepts the signals
659 .\"O .B SIGINT
660 .\"O and
661 .\"O .B SIGQUIT
662 .\"O via a signalfd file descriptor.
663 .\"O The program terminates after accepting a
664 .\"O .B SIGQUIT
665 .\"O signal.
666 .\"O The following shell session demonstrates the use of the program:
667 ²¼µ­¤Î¥×¥í¥°¥é¥à¤Ï¡¢¥·¥°¥Ê¥ë
668 .B SIGINT
669 ¤È
670 .B SIGQUIT
671 ¤ò signalfd ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿·Ðͳ¤Ç¼õ¿®¤¹¤ë¡£
672 ¥·¥°¥Ê¥ë
673 .B SIGQUIT
674 ¼õ¿®¸å¤Ë¥×¥í¥°¥é¥à¤Ï½ªÎ»¤¹¤ë¡£
675 °Ê²¼¤Ë¼¨¤¹¥·¥§¥ë¥»¥Ã¥·¥ç¥ó¤Ë¤³¤Î¥×¥í¥°¥é¥à¤Î»È¤¤Êý¤ò¼¨¤¹¡£
676 .in +4n
677 .nf
678
679 .RB "$" " ./signalfd_demo"
680 .BR "^C" "                   # Control\-C generates SIGINT"
681 Got SIGINT
682 .B ^C
683 Got SIGINT
684 \fB^\\\fP                    # Control\-\\ generates SIGQUIT
685 Got SIGQUIT
686 $
687 .fi
688 .in
689 .\"O .SS Program source
690 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
691 \&
692 .nf
693 #include <sys/signalfd.h>
694 #include <signal.h>
695 #include <unistd.h>
696 #include <stdlib.h>
697 #include <stdio.h>
698
699 #define handle_error(msg) \\
700     do { perror(msg); exit(EXIT_FAILURE); } while (0)
701
702 int
703 main(int argc, char *argv[])
704 {
705     sigset_t mask;
706     int sfd;
707     struct signalfd_siginfo fdsi;
708     ssize_t s;
709
710     sigemptyset(&mask);
711     sigaddset(&mask, SIGINT);
712     sigaddset(&mask, SIGQUIT);
713
714     /* Block signals so that they aren\(aqt handled
715        according to their default dispositions */
716
717     if (sigprocmask(SIG_BLOCK, &mask, NULL) == \-1)
718         handle_error("sigprocmask");
719
720     sfd = signalfd(\-1, &mask, 0);
721     if (sfd == \-1)
722         handle_error("signalfd");
723
724     for (;;) {
725         s = read(sfd, &fdsi, sizeof(struct signalfd_siginfo));
726         if (s != sizeof(struct signalfd_siginfo))
727             handle_error("read");
728
729         if (fdsi.ssi_signo == SIGINT) {
730             printf("Got SIGINT\\n");
731         } else if (fdsi.ssi_signo == SIGQUIT) {
732             printf("Got SIGQUIT\\n");
733             exit(EXIT_SUCCESS);
734         } else {
735             printf("Read unexpected signal\\n");
736         }
737     }
738 }
739 .fi
740 .\"O .SH "SEE ALSO"
741 .SH ´ØÏ¢¹àÌÜ
742 .BR eventfd (2),
743 .BR poll (2),
744 .BR read (2),
745 .BR select (2),
746 .BR sigaction (2),
747 .BR sigprocmask (2),
748 .BR sigwaitinfo (2),
749 .BR timerfd_create (2),
750 .BR sigsetops (3),
751 .BR sigwait (3),
752 .BR epoll (7),
753 .BR signal (7)