1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (C) 1997 Andries Brouwer (aeb@cwi.nl)
.\" and Copyright (C) 2006, Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Additions from Richard Gooch <rgooch@atnf.CSIRO.AU> and aeb, 971207
.\" 2006-03-13, mtk, Added ppoll() + various other rewordings
.\" 2006-07-01, mtk, Added POLLRDHUP + various other wording and
.\" formatting changes.
.\"
.\" FIXME . 2.6.17 has a definition for POLLREMOVE, but this
.\" flag is not used in the code. Check later to see if it
.\" does get a use. 2.6.21 still shows no use.
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated 1997-12-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified 2004-05-22, Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified 2005-01-03, Yuichi SATO
.\" Updated & Modified 2005-10-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
.\" Updated 2006-04-16, Akihiro MOTOKI, Catch up to LDP man-pages 2.28
.\" Updated 2006-07-23, Akihiro MOTOKI, Catch up to LDP man-pages 2.36
.\"
.\"WORD: descriptor ǥץ
.\"
.TH POLL 2 2006-03-13 "Linux" "Linux Programmer's Manual"
.SH ̾
poll, ppoll \- եǥץˤ륤٥ȤԤ
.SH
.nf
.B #include <poll.h>
.sp
.BI "int poll(struct pollfd *" fds ", nfds_t " nfds ", int " timeout );
.sp
.B #define _GNU_SOURCE
.B #include <poll.h>
.sp
.BI "int ppoll(struct pollfd *" fds ", nfds_t " nfds ", "
.BI " const struct timespec *" timeout ", const sigset_t *" sigmask );
.fi
.SH
.BR poll ()
.BR select (2)
ƱͤλŻԤĤޤꡢեǥץΤ줫Ĥ
I/O ¹Բǽʾ֤ˤʤΤԤġ
ƻ뤹եǥץϡ
.I fds
ǻꤹ롣
.I fds
ϡʲηι¤Τ
.I nfds
ĤǤ롣
.in +4n
.nf
struct pollfd {
int fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
.fi
.in
¤Τ
.I fd
ˤϥץեΥեǥץ롣
¤Τ
.I events
Ǥϥѥǡץꥱ̣äƤ륤٥Ȥ
ӥåȥޥꤹ롣
.I revents
ǤϽϥѥǡºݤ˵ä٥Ȥͥˤꤵ롣
.I revents
֤ӥåˤϡ
.I events
ǻꤷΤΤɤ줫⤷
.BR POLLERR ,
.BR POLLHUP ,
.B POLLNVAL
ΤΰĤޤޤ
.RB ( POLLERR ,
.BR POLLHUP ,
.B POLLNVAL
3ĤΥӥåȤ
.I events
˻ꤷƤ̣ʤб֤ξ
.I revents
ꤵ)
ɤΥեǥץˤᤷ٥ȤȯƤ餺
顼ⵯʤ硢
.BR poll ()
ϥ٥ȤΤ줫Ĥȯޤ (block) 롣
.I timeout
.BR poll ()
ߤ֤ξ¤ꤹΤǡߥñ̤ǻꤹ롣
.I timeout
ͤꤹȡॢȻ̵֤¤Ȥʤ롣
.I events
˻ꤷꡢ
.I revents
֤ӥåȤ \fI<poll.h>\fP Ƥ:
.RS
.TP
.B POLLIN
ɤ߽Фǽʥǡ롣
.TP
.B POLLPRI
ɤ߽Фǽʶ۵ޥǡ (urgent data)
(㤨СTCP åȤӰ賰 (out-of-band data) ǡ䡢
ѥåȥ⡼ɤεüΥޥ졼¦ѲĤȤ)
.TP
.B POLLOUT
ߤ (block) ʤ֤Ǥ롣
.TP
.BR POLLRDHUP " (Linux 2.6.17 ʹ)"
ȥॽåȤ¾üͥ close
ͥν¦ shutdown
ͭˤˤϡ
.B _GNU_SOURCE
ǽޥʤФʤʤ
.TP
.B POLLERR
顼 (ϤξΤ)
.TP
.B POLLHUP
ϥåפ (ϤξΤ)
.TP
.B POLLNVAL
:
.I fd
ץƤʤ (ϤξΤ)
.RE
.PP
.B _XOPEN_SOURCE
ƥѥ뤷ˤϡʲԤ롣
嵭ΥꥹȤˤӥåȰʾξǤϤʤ
.RS
.TP
.B POLLRDNORM
.B POLLIN
Ʊ
.TP
.B POLLRDBAND
ͥӰǡ (priority band data) ɤ߽ФǽǤ
(̤ Linux ǤϻѤʤ)
.\" POLLRDBAND is used in the DECnet protocol.
.TP
.B POLLWRNORM
.B POLLOUT
Ʊ
.TP
.B POLLWRBAND
ͥӰǡ (priority data) ߲ǽǤ롣
.RE
.PP
Linux Ǥ
.B POLLMSG
Ƥ뤬ѤƤʤ
.SS ppoll()
.BR poll ()
.BR ppoll ()
δط
.BR select (2)
.BR pselect (2)
δطƱ褦ʤΤǤ:
.BR pselect (2)
Ʊͤˡ
.BR ppoll ()
ȤȡץꥱϥեǥץξѲ
⤷ϥʥªԤĤȤǤ롣
.PP
.I timeout
ΰ㤤ȡʲ
.BR ppoll ()
θƤӽФϡ
.nf
ready = ppoll(&fds, nfds, timeout, &sigmask);
.fi
Υ
.I atomic
˼¹ԤΤǤ롣
.nf
sigset_t origmask;
sigprocmask(SIG_SETMASK, &sigmask, &origmask);
ready = poll(&fds, nfds, timeout);
sigprocmask(SIG_SETMASK, &origmask, NULL);
.fi
.PP
ʤ
.BR ppoll ()
ɬפʤΤˤĤƤ
.BR pselect (2)
ȤΤȡ
.I timeout
.BR ppoll ()
ߤ֤ξ¤ꤹΤǤ롣
ΰˤϰʲηι¤ΤؤΥݥꤹ롣
.in +4n
.nf
struct timespec {
long tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
.fi
.in
.I timeout
NULL ꤵ줿硢
.B ppoll
̵¤ߤ뤳Ȥ롣
.SH ֤
ο֤ο 0 ʳ
.I revents
ǤŤΤοǤ (̤θȡΥǥץ
ˤϥ٥Ȥ顼𤬤)
0 ϡॢȤȤʤꡢɤΥեǥץǤ⥤٥Ȥ
ȯʤäȤ顼ξ \-1 ֤졢
.I errno
Ŭڤꤵ롣
.SH 顼
.TP
.B EBADF
Τɤ줫ʥեǥץޤޤƤ롣
.TP
.B EFAULT
ȤƻꤷƤӽФץΥɥ쥹֤
ޤޤƤʤ
.TP
.B EINTR
ᤵ줿٥ȤΤɤ줫˥ʥ뤬ȯ
.TP
.B EINVAL
.I nfds
ͤ
.B RLIMIT_NOFILE
Ķ
.TP
.B ENOMEM
եǥץơ֥ݤ뤿Υ꤬ʤ
.SH С
.BR poll ()
ƥॳ Linux 2.1.23 Ƴ줿
.BR poll ()
饤֥ꡦ libc 5.4.28 Ƴ줿
(ϥͥ뤬
.BR poll ()
ƥॳݡȤƤʤ
.BR select (2)
Ѥƥߥ졼ȤԤ)
.BR ppoll ()
ƥॳ ͥ 2.6.16 Linux ɲä줿
.BR ppoll ()
饤֥ꥳ glibc 2.4 ɲä줿
.SH
.BR poll ()
POSIX.1-2001 ˽Ƥ롣
.BR ppoll ()
Linux ͭǤ롣
.\" NetBSD 3.0 ˤ pollts() 롣
.\" pollts() Linux ppoll () Ʊ褦ʤΤǤ롣
.SH
ĤμǤϡ \-1 äɸ
.B INFTIM
Ƥꡢ
.I timeout
λ˻ѤǤ롣
glibc ǤƤʤ
.SS "Linux Ǥ"
Linux
.BR ppoll ()
ƥॳ
.I timeout
ѹ롣
glibc ΥåѡؿϡƥॳϤ timeout
ȤƥѿȤȤǤưäƤ롣
Τᡢglibc
.BR ppoll ()
ؿ
.I timeout
ѹʤ
.SH Х
.BR select (2)
Ρ֥Хפ˽Ƥ롢äλ (spurious readiness
notifications) ˤĤƤεȤΤȡ
.SH Ϣ
.BR select (2),
.BR select_tut (2),
.BR feature_test_macros (7)
|