Debian Codegraph @

templates/man2/poll.2.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:35+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "poll"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-08"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid "poll, ppoll - wait for some event on a file descriptor"
50 msgstr ""
51
52 #. type: SH
53 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
54 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
55 #, no-wrap
56 msgid "LIBRARY"
57 msgstr ""
58
59 #. type: Plain text
60 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
61 #: opensuse-leap-16-1 opensuse-tumbleweed
62 msgid "Standard C library (I<libc>,\\ I<-lc>)"
63 msgstr ""
64
65 #. type: SH
66 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
67 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
68 #, no-wrap
69 msgid "SYNOPSIS"
70 msgstr ""
71
72 #. type: Plain text
73 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
74 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
75 #, no-wrap
76 msgid "B<#include E<lt>poll.hE<gt>>\n"
77 msgstr ""
78
79 #. type: Plain text
80 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
81 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
82 #, no-wrap
83 msgid "B<int poll(struct pollfd *>I<fds>B<, nfds_t >I<nfds>B<, int >I<timeout>B<);>\n"
84 msgstr ""
85
86 #. type: Plain text
87 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
88 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
89 #, no-wrap
90 msgid ""
91 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
92 "B<#include E<lt>poll.hE<gt>>\n"
93 msgstr ""
94
95 #. type: Plain text
96 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
97 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
98 #, no-wrap
99 msgid ""
100 "B<int ppoll(struct pollfd *>I<fds>B<, nfds_t >I<nfds>B<,>\n"
101 "B< const struct timespec *_Nullable >I<tmo_p>B<,>\n"
102 "B< const sigset_t *_Nullable >I<sigmask>B<);>\n"
103 msgstr ""
104
105 #. type: SH
106 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
107 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
108 #, no-wrap
109 msgid "DESCRIPTION"
110 msgstr ""
111
112 #. type: Plain text
113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
115 msgid ""
116 "B<poll>() performs a similar task to B<select>(2): it waits for one of a "
117 "set of file descriptors to become ready to perform I/O. The Linux-specific "
118 "B<epoll>(7) API performs a similar task, but offers features beyond those "
119 "found in B<poll>()."
120 msgstr ""
121
122 #. type: Plain text
123 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
124 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
125 msgid ""
126 "The set of file descriptors to be monitored is specified in the I<fds> "
127 "argument, which is an array of structures of the following form:"
128 msgstr ""
129
130 #. type: Plain text
131 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
132 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
133 #, no-wrap
134 msgid ""
135 "struct pollfd {\n"
136 " int fd; /* file descriptor */\n"
137 " short events; /* requested events */\n"
138 " short revents; /* returned events */\n"
139 "};\n"
140 msgstr ""
141
142 #. type: Plain text
143 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
144 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
145 msgid ""
146 "The caller should specify the number of items in the I<fds> array in I<nfds>."
147 msgstr ""
148
149 #. type: Plain text
150 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
151 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
152 msgid ""
153 "The field I<fd> contains a file descriptor for an open file. If this field "
154 "is negative, then the corresponding I<events> field is ignored and the "
155 "I<revents> field returns zero. (This provides an easy way of ignoring a "
156 "file descriptor for a single B<poll>() call: simply set the I<fd> field to "
157 "its bitwise complement.)"
158 msgstr ""
159
160 #. type: Plain text
161 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
162 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
163 msgid ""
164 "The field I<events> is an input parameter, a bit mask specifying the events "
165 "the application is interested in for the file descriptor I<fd>. This field "
166 "may be specified as zero, in which case the only events that can be returned "
167 "in I<revents> are B<POLLHUP>, B<POLLERR>, and B<POLLNVAL> (see below)."
168 msgstr ""
169
170 #. type: Plain text
171 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
172 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
173 msgid ""
174 "The field I<revents> is an output parameter, filled by the kernel with the "
175 "events that actually occurred. The bits returned in I<revents> can include "
176 "any of those specified in I<events>, or one of the values B<POLLERR>, "
177 "B<POLLHUP>, or B<POLLNVAL>. (These three bits are meaningless in the "
178 "I<events> field, and will be set in the I<revents> field whenever the "
179 "corresponding condition is true.)"
180 msgstr ""
181
182 #. type: Plain text
183 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
184 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
185 msgid ""
186 "If none of the events requested (and no error) has occurred for any of the "
187 "file descriptors, then B<poll>() blocks until one of the events occurs."
188 msgstr ""
189
190 #. type: Plain text
191 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
192 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
193 msgid ""
194 "The I<timeout> argument specifies the number of milliseconds that B<poll>() "
195 "should block waiting for a file descriptor to become ready. The call will "
196 "block until either:"
197 msgstr ""
198
199 #. type: IP
200 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
201 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
202 #, no-wrap
203 msgid "\\[bu]"
204 msgstr ""
205
206 #. type: Plain text
207 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
208 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
209 msgid "a file descriptor becomes ready;"
210 msgstr ""
211
212 #. type: Plain text
213 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
214 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
215 msgid "the call is interrupted by a signal handler; or"
216 msgstr ""
217
218 #. type: Plain text
219 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
220 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
221 msgid "the timeout expires."
222 msgstr ""
223
224 #. type: Plain text
225 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
226 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
227 msgid ""
228 "Being \"ready\" means that the requested operation will not block; thus, "
229 "B<poll>()ing regular files, block devices, and other files with no "
230 "reasonable polling semantic I<always> returns instantly as ready to read and "
231 "write."
232 msgstr ""
233
234 #. type: Plain text
235 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
236 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
237 msgid ""
238 "Note that the I<timeout> interval will be rounded up to the system clock "
239 "granularity, and kernel scheduling delays mean that the blocking interval "
240 "may overrun by a small amount. Specifying a negative value in I<timeout> "
241 "means an infinite timeout. Specifying a I<timeout> of zero causes "
242 "B<poll>() to return immediately, even if no file descriptors are ready."
243 msgstr ""
244
245 #. type: Plain text
246 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
247 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
248 msgid ""
249 "The bits that may be set/returned in I<events> and I<revents> are defined in "
250 "I<E<lt>poll.hE<gt>>:"
251 msgstr ""
252
253 #. type: TP
254 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
255 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
256 #, no-wrap
257 msgid "B<POLLIN>"
258 msgstr ""
259
260 #. type: Plain text
261 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
262 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
263 msgid "There is data to read."
264 msgstr ""
265
266 #. type: TP
267 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
268 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
269 #, no-wrap
270 msgid "B<POLLPRI>"
271 msgstr ""
272
273 #. type: Plain text
274 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
275 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
276 msgid ""
277 "There is some exceptional condition on the file descriptor. Possibilities "
278 "include:"
279 msgstr ""
280
281 #. type: Plain text
282 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
283 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
284 msgid "There is out-of-band data on a TCP socket (see B<tcp>(7))."
285 msgstr ""
286
287 #. type: Plain text
288 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
289 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
290 msgid ""
291 "A pseudoterminal master in packet mode has seen a state change on the slave "
292 "(see B<ioctl_tty>(2))."
293 msgstr ""
294
295 #. type: Plain text
296 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
297 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
298 msgid "A I<cgroup.events> file has been modified (see B<cgroups>(7))."
299 msgstr ""
300
301 #. type: TP
302 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
303 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
304 #, no-wrap
305 msgid "B<POLLOUT>"
306 msgstr ""
307
308 #. type: Plain text
309 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
310 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
311 msgid ""
312 "Writing is now possible, though a write larger than the available space in a "
313 "socket or pipe will still block (unless B<O_NONBLOCK> is set)."
314 msgstr ""
315
316 #. type: TP
317 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
318 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
319 #, no-wrap
320 msgid "B<POLLRDHUP> (since Linux 2.6.17)"
321 msgstr ""
322
323 #. type: Plain text
324 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
325 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
326 msgid ""
327 "Stream socket peer closed connection, or shut down writing half of "
328 "connection. The B<_GNU_SOURCE> feature test macro must be defined (before "
329 "including I<any> header files) in order to obtain this definition."
330 msgstr ""
331
332 #. type: TP
333 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
334 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
335 #, no-wrap
336 msgid "B<POLLERR>"
337 msgstr ""
338
339 #. type: Plain text
340 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
341 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
342 msgid ""
343 "Error condition (only returned in I<revents>; ignored in I<events>). This "
344 "bit is also set for a file descriptor referring to the write end of a pipe "
345 "when the read end has been closed."
346 msgstr ""
347
348 #. type: TP
349 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
350 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
351 #, no-wrap
352 msgid "B<POLLHUP>"
353 msgstr ""
354
355 #. type: Plain text
356 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
357 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
358 msgid ""
359 "Hang up (only returned in I<revents>; ignored in I<events>). Note that when "
360 "reading from a channel such as a pipe or a stream socket, this event merely "
361 "indicates that the peer closed its end of the channel. Subsequent reads "
362 "from the channel will return 0 (end of file) only after all outstanding "
363 "data in the channel has been consumed."
364 msgstr ""
365
366 #. type: TP
367 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
368 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
369 #, no-wrap
370 msgid "B<POLLNVAL>"
371 msgstr ""
372
373 #. type: Plain text
374 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
375 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
376 msgid ""
377 "Invalid request: I<fd> not open (only returned in I<revents>; ignored in "
378 "I<events>)."
379 msgstr ""
380
381 #. type: Plain text
382 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
383 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
384 msgid ""
385 "When compiling with B<_XOPEN_SOURCE> defined, one also has the following, "
386 "which convey no further information beyond the bits listed above:"
387 msgstr ""
388
389 #. type: TP
390 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
391 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
392 #, no-wrap
393 msgid "B<POLLRDNORM>"
394 msgstr ""
395
396 #. type: Plain text
397 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
398 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
399 msgid "Equivalent to B<POLLIN>."
400 msgstr ""
401
402 #. type: TP
403 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
404 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
405 #, no-wrap
406 msgid "B<POLLRDBAND>"
407 msgstr ""
408
409 #. POLLRDBAND is used in the DECnet protocol.
410 #. type: Plain text
411 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
412 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
413 msgid "Priority band data can be read (generally unused on Linux)."
414 msgstr ""
415
416 #. type: TP
417 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
418 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
419 #, no-wrap
420 msgid "B<POLLWRNORM>"
421 msgstr ""
422
423 #. type: Plain text
424 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
425 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
426 msgid "Equivalent to B<POLLOUT>."
427 msgstr ""
428
429 #. type: TP
430 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
431 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
432 #, no-wrap
433 msgid "B<POLLWRBAND>"
434 msgstr ""
435
436 #. type: Plain text
437 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
438 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
439 msgid "Priority data may be written."
440 msgstr ""
441
442 #. type: Plain text
443 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
444 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
445 msgid "Linux also knows about, but does not use B<POLLMSG>."
446 msgstr ""
447
448 #. type: SS
449 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
450 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
451 #, no-wrap
452 msgid "ppoll()"
453 msgstr ""
454
455 #. type: Plain text
456 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
457 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
458 msgid ""
459 "The relationship between B<poll>() and B<ppoll>() is analogous to the "
460 "relationship between B<select>(2) and B<pselect>(2): like B<pselect>(2), "
461 "B<ppoll>() allows an application to safely wait until either a file "
462 "descriptor becomes ready or until a signal is caught."
463 msgstr ""
464
465 #. type: Plain text
466 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
467 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
468 msgid ""
469 "Other than the difference in the precision of the I<timeout> argument, the "
470 "following B<ppoll>() call:"
471 msgstr ""
472
473 #. type: Plain text
474 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
475 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
476 #, no-wrap
477 msgid "ready = ppoll(&fds, nfds, tmo_p, &sigmask);\n"
478 msgstr ""
479
480 #. type: Plain text
481 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
482 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
483 msgid "is nearly equivalent to I<atomically> executing the following calls:"
484 msgstr ""
485
486 #. type: Plain text
487 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
488 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
489 #, no-wrap
490 msgid ""
491 "sigset_t origmask;\n"
492 "int timeout;\n"
493 "\\&\n"
494 "timeout = (tmo_p == NULL) ? -1 :\n"
495 " (tmo_p-E<gt>tv_sec * 1000 + tmo_p-E<gt>tv_nsec / 1000000);\n"
496 "pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);\n"
497 "ready = poll(&fds, nfds, timeout);\n"
498 "pthread_sigmask(SIG_SETMASK, &origmask, NULL);\n"
499 msgstr ""
500
501 #. type: Plain text
502 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
503 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
504 msgid ""
505 "The above code segment is described as I<nearly> equivalent because whereas "
506 "a negative I<timeout> value for B<poll>() is interpreted as an infinite "
507 "timeout, a negative value expressed in I<*tmo_p> results in an error from "
508 "B<ppoll>()."
509 msgstr ""
510
511 #. type: Plain text
512 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
513 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
514 msgid ""
515 "See the description of B<pselect>(2) for an explanation of why B<ppoll>() "
516 "is necessary."
517 msgstr ""
518
519 #. type: Plain text
520 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
521 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
522 msgid ""
523 "If the I<sigmask> argument is specified as NULL, then no signal mask "
524 "manipulation is performed (and thus B<ppoll>() differs from B<poll>() only "
525 "in the precision of the I<timeout> argument)."
526 msgstr ""
527
528 #. type: Plain text
529 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
530 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
531 msgid ""
532 "The I<tmo_p> argument specifies an upper limit on the amount of time that "
533 "B<ppoll>() will block. This argument is a pointer to a B<timespec>(3) "
534 "structure."
535 msgstr ""
536
537 #. type: Plain text
538 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
539 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
540 msgid ""
541 "If I<tmo_p> is specified as NULL, then B<ppoll>() can block indefinitely."
542 msgstr ""
543
544 #. type: SH
545 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
546 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
547 #, no-wrap
548 msgid "RETURN VALUE"
549 msgstr ""
550
551 #. type: Plain text
552 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
553 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
554 msgid ""
555 "On success, B<poll>() returns a nonnegative value which is the number of "
556 "elements in the I<pollfds> whose I<revents> fields have been set to a "
557 "nonzero value (indicating an event or an error). A return value of zero "
558 "indicates that the system call timed out before any file descriptors became "
559 "ready."
560 msgstr ""
561
562 #. type: Plain text
563 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
564 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
565 msgid "On error, -1 is returned, and I<errno> is set to indicate the error."
566 msgstr ""
567
568 #. type: SH
569 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
570 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
571 #, no-wrap
572 msgid "ERRORS"
573 msgstr ""
574
575 #. type: TP
576 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
577 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
578 #, no-wrap
579 msgid "B<EFAULT>"
580 msgstr ""
581
582 #. type: Plain text
583 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
584 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
585 msgid ""
586 "I<fds> points outside the process's accessible address space. The array "
587 "given as argument was not contained in the calling program's address space."
588 msgstr ""
589
590 #. type: TP
591 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
592 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
593 #, no-wrap
594 msgid "B<EINTR>"
595 msgstr ""
596
597 #. type: Plain text
598 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
599 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
600 msgid "A signal occurred before any requested event; see B<signal>(7)."
601 msgstr ""
602
603 #. type: TP
604 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
605 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
606 #, no-wrap
607 msgid "B<EINVAL>"
608 msgstr ""
609
610 #. type: Plain text
611 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
612 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
613 msgid "The I<nfds> value exceeds the B<RLIMIT_NOFILE> value."
614 msgstr ""
615
616 #. type: Plain text
617 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
618 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
619 msgid ""
620 "(B<ppoll>()) The timeout value expressed in I<*tmo_p> is invalid (negative)."
621 msgstr ""
622
623 #. type: TP
624 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
625 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
626 #, no-wrap
627 msgid "B<ENOMEM>"
628 msgstr ""
629
630 #. type: Plain text
631 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
632 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
633 msgid "Unable to allocate memory for kernel data structures."
634 msgstr ""
635
636 #. type: SH
637 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
638 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
639 #, no-wrap
640 msgid "VERSIONS"
641 msgstr ""
642
643 #. Darwin, according to a report by Jeremy Sequoia, relayed by Josh Triplett
644 #. type: Plain text
645 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
646 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
647 msgid ""
648 "On some other UNIX systems, B<poll>() can fail with the error B<EAGAIN> if "
649 "the system fails to allocate kernel-internal resources, rather than "
650 "B<ENOMEM> as Linux does. POSIX permits this behavior. Portable programs "
651 "may wish to check for B<EAGAIN> and loop, just as with B<EINTR>."
652 msgstr ""
653
654 #. type: Plain text
655 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
656 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
657 msgid ""
658 "Some implementations define the nonstandard constant B<INFTIM> with the "
659 "value -1 for use as a I<timeout> for B<poll>(). This constant is not "
660 "provided in glibc."
661 msgstr ""
662
663 #. type: SS
664 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
665 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
666 #, no-wrap
667 msgid "C library/kernel differences"
668 msgstr ""
669
670 #. type: Plain text
671 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
672 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
673 msgid ""
674 "The Linux B<ppoll>() system call modifies its I<tmo_p> argument. However, "
675 "the glibc wrapper function hides this behavior by using a local variable for "
676 "the timeout argument that is passed to the system call. Thus, the glibc "
677 "B<ppoll>() function does not modify its I<tmo_p> argument."
678 msgstr ""
679
680 #. type: Plain text
681 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
682 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
683 msgid ""
684 "The raw B<ppoll>() system call has a fifth argument, I<size_t sigsetsize>, "
685 "which specifies the size in bytes of the I<sigmask> argument. The glibc "
686 "B<ppoll>() wrapper function specifies this argument as a fixed value (equal "
687 "to I<sizeof(kernel_sigset_t)>). See B<sigprocmask>(2) for a discussion on "
688 "the differences between the kernel and the libc notion of the sigset."
689 msgstr ""
690
691 #. type: SH
692 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
693 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
694 #, no-wrap
695 msgid "STANDARDS"
696 msgstr ""
697
698 #. type: Plain text
699 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
700 #: opensuse-tumbleweed
701 msgid "POSIX.1-2024."
702 msgstr ""
703
704 #. type: SH
705 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
706 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
707 #, no-wrap
708 msgid "HISTORY"
709 msgstr ""
710
711 #. type: TP
712 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
713 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
714 #, no-wrap
715 msgid "B<poll>()"
716 msgstr ""
717
718 #. type: Plain text
719 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
720 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
721 msgid "POSIX.1-2001. Linux 2.1.23."
722 msgstr ""
723
724 #. type: Plain text
725 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
726 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
727 msgid ""
728 "On older kernels that lack this system call, the glibc B<poll>() wrapper "
729 "function provides emulation using B<select>(2)."
730 msgstr ""
731
732 #. type: TP
733 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
734 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
735 #, no-wrap
736 msgid "B<ppoll>()"
737 msgstr ""
738
739 #. type: Plain text
740 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
741 #: opensuse-tumbleweed
742 msgid "POSIX.1-2024. Linux 2.6.16, glibc 2.4."
743 msgstr ""
744
745 #. type: SH
746 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
747 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
748 #, no-wrap
749 msgid "NOTES"
750 msgstr ""
751
752 #. type: Plain text
753 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
754 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
755 msgid ""
756 "The operation of B<poll>() and B<ppoll>() is not affected by the "
757 "B<O_NONBLOCK> flag."
758 msgstr ""
759
760 #. type: Plain text
761 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
762 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
763 msgid ""
764 "For a discussion of what may happen if a file descriptor being monitored by "
765 "B<poll>() is closed in another thread, see B<select>(2)."
766 msgstr ""
767
768 #. type: SH
769 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
770 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
771 #, no-wrap
772 msgid "BUGS"
773 msgstr ""
774
775 #. type: Plain text
776 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
777 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
778 msgid ""
779 "See the discussion of spurious readiness notifications under the BUGS "
780 "section of B<select>(2)."
781 msgstr ""
782
783 #. type: SH
784 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
785 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
786 #, no-wrap
787 msgid "EXAMPLES"
788 msgstr ""
789
790 #. type: Plain text
791 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
792 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
793 msgid ""
794 "The program below opens each of the files named in its command-line "
795 "arguments and monitors the resulting file descriptors for readiness to read "
796 "(B<POLLIN>). The program loops, repeatedly using B<poll>() to monitor the "
797 "file descriptors, printing the number of ready file descriptors on return. "
798 "For each ready file descriptor, the program:"
799 msgstr ""
800
801 #. type: Plain text
802 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
803 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
804 msgid "displays the returned I<revents> field in a human-readable form;"
805 msgstr ""
806
807 #. type: Plain text
808 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
809 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
810 msgid ""
811 "if the file descriptor is readable, reads some data from it, and displays "
812 "that data on standard output; and"
813 msgstr ""
814
815 #. type: Plain text
816 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
817 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
818 msgid ""
819 "if the file descriptor was not readable, but some other event occurred "
820 "(presumably B<POLLHUP>), closes the file descriptor."
821 msgstr ""
822
823 #. type: Plain text
824 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
825 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
826 msgid "Suppose we run the program in one terminal, asking it to open a FIFO:"
827 msgstr ""
828
829 #. type: Plain text
830 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
831 #: opensuse-tumbleweed
832 #, no-wrap
833 msgid ""
834 "$B< mkfifo myfifo>;\n"
835 "$B< ./poll_input myfifo>;\n"
836 msgstr ""
837
838 #. type: Plain text
839 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
840 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
841 msgid ""
842 "In a second terminal window, we then open the FIFO for writing, write some "
843 "data to it, and close the FIFO:"
844 msgstr ""
845
846 #. type: Plain text
847 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
848 #: opensuse-tumbleweed
849 #, no-wrap
850 msgid "$B< echo aaaaabbbbbccccc E<gt> myfifo>;\n"
851 msgstr ""
852
853 #. type: Plain text
854 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
855 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
856 msgid "In the terminal where we are running the program, we would then see:"
857 msgstr ""
858
859 #. type: Plain text
860 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
861 #: opensuse-tumbleweed
862 #, no-wrap
863 msgid ""
864 "Opened \"myfifo\" on fd 3\n"
865 "About to poll()\n"
866 "Ready: 1\n"
867 " fd=3; events: POLLIN POLLHUP\n"
868 " read 10 bytes: aaaaabbbbb\n"
869 "About to poll()\n"
870 "Ready: 1\n"
871 " fd=3; events: POLLIN POLLHUP\n"
872 " read 6 bytes: ccccc\n"
873 "\\&\n"
874 "About to poll()\n"
875 "Ready: 1\n"
876 " fd=3; events: POLLHUP\n"
877 " closing fd 3\n"
878 "All file descriptors closed. Bye.\n"
879 msgstr ""
880
881 #. type: Plain text
882 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
883 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
884 msgid "In the above output, we see that B<poll>() returned three times:"
885 msgstr ""
886
887 #. type: Plain text
888 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
889 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
890 msgid ""
891 "On the first return, the bits returned in the I<revents> field were "
892 "B<POLLIN>, indicating that the file descriptor is readable, and B<POLLHUP>, "
893 "indicating that the other end of the FIFO has been closed. The program then "
894 "consumed some of the available input."
895 msgstr ""
896
897 #. type: Plain text
898 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
899 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
900 msgid ""
901 "The second return from B<poll>() also indicated B<POLLIN> and B<POLLHUP>; "
902 "the program then consumed the last of the available input."
903 msgstr ""
904
905 #. type: Plain text
906 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
907 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
908 msgid ""
909 "On the final return, B<poll>() indicated only B<POLLHUP> on the FIFO, at "
910 "which point the file descriptor was closed and the program terminated."
911 msgstr ""
912
913 #. type: SS
914 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
915 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
916 #, no-wrap
917 msgid "Program source"
918 msgstr ""
919
920 #. type: Plain text
921 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
922 #: opensuse-tumbleweed
923 #, no-wrap
924 msgid ""
925 "/* poll_input.c\n"
926 "\\&\n"
927 " Licensed under GNU General Public License v2 or later.\n"
928 "*/\n"
929 "#include E<lt>err.hE<gt>\n"
930 "#include E<lt>fcntl.hE<gt>\n"
931 "#include E<lt>poll.hE<gt>\n"
932 "#include E<lt>stdio.hE<gt>\n"
933 "#include E<lt>stdlib.hE<gt>\n"
934 "#include E<lt>sys/types.hE<gt>\n"
935 "#include E<lt>unistd.hE<gt>\n"
936 "\\&\n"
937 "int\n"
938 "main(int argc, char *argv[])\n"
939 "{\n"
940 " int ready;\n"
941 " char buf[10];\n"
942 " nfds_t num_open_fds, nfds;\n"
943 " ssize_t s;\n"
944 " struct pollfd *pfds;\n"
945 "\\&\n"
946 " if (argc E<lt> 2) {\n"
947 " fprintf(stderr, \"Usage: %s file...\\[rs]n\", argv[0]);\n"
948 " exit(EXIT_FAILURE);\n"
949 " }\n"
950 "\\&\n"
951 " num_open_fds = nfds = argc - 1;\n"
952 " pfds = calloc(nfds, sizeof(struct pollfd));\n"
953 " if (pfds == NULL)\n"
954 " err(EXIT_FAILURE, \"malloc\");\n"
955 "\\&\n"
956 " /* Open each file on command line, and add it to \\[aq]pfds\\[aq] array. */\n"
957 "\\&\n"
958 " for (nfds_t j = 0; j E<lt> nfds; j++) {\n"
959 " pfds[j].fd = open(argv[j + 1], O_RDONLY);\n"
960 " if (pfds[j].fd == -1)\n"
961 " err(EXIT_FAILURE, \"open\");\n"
962 "\\&\n"
963 " printf(\"Opened \\[rs]\"%s\\[rs]\" on fd %d\\[rs]n\", argv[j + 1], pfds[j].fd);\n"
964 "\\&\n"
965 " pfds[j].events = POLLIN;\n"
966 " }\n"
967 "\\&\n"
968 " /* Keep calling poll() as long as at least one file descriptor is\n"
969 " open. */\n"
970 "\\&\n"
971 " while (num_open_fds E<gt> 0) {\n"
972 " printf(\"About to poll()\\[rs]n\");\n"
973 " ready = poll(pfds, nfds, -1);\n"
974 " if (ready == -1)\n"
975 " err(EXIT_FAILURE, \"poll\");\n"
976 "\\&\n"
977 " printf(\"Ready: %d\\[rs]n\", ready);\n"
978 "\\&\n"
979 " /* Deal with array returned by poll(). */\n"
980 "\\&\n"
981 " for (nfds_t j = 0; j E<lt> nfds; j++) {\n"
982 " if (pfds[j].revents != 0) {\n"
983 " printf(\" fd=%d; events: %s%s%s\\[rs]n\", pfds[j].fd,\n"
984 " (pfds[j].revents & POLLIN) ? \"POLLIN \" : \"\",\n"
985 " (pfds[j].revents & POLLHUP) ? \"POLLHUP \" : \"\",\n"
986 " (pfds[j].revents & POLLERR) ? \"POLLERR \" : \"\");\n"
987 "\\&\n"
988 " if (pfds[j].revents & POLLIN) {\n"
989 " s = read(pfds[j].fd, buf, sizeof(buf));\n"
990 " if (s == -1)\n"
991 " err(EXIT_FAILURE, \"read\");\n"
992 " printf(\" read %zd bytes: %.*s\\[rs]n\",\n"
993 " s, (int) s, buf);\n"
994 " } else { /* POLLERR | POLLHUP */\n"
995 " printf(\" closing fd %d\\[rs]n\", pfds[j].fd);\n"
996 " if (close(pfds[j].fd) == -1)\n"
997 " err(EXIT_FAILURE, \"close\");\n"
998 " num_open_fds--;\n"
999 " }\n"
1000 " }\n"
1001 " }\n"
1002 " }\n"
1003 "\\&\n"
1004 " printf(\"All file descriptors closed. Bye.\\[rs]n\");\n"
1005 " exit(EXIT_SUCCESS);\n"
1006 "}\n"
1007 msgstr ""
1008
1009 #. SRC END
1010 #. type: SH
1011 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1012 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1013 #, no-wrap
1014 msgid "SEE ALSO"
1015 msgstr ""
1016
1017 #. type: Plain text
1018 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1019 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1020 msgid ""
1021 "B<restart_syscall>(2), B<select>(2), B<select_tut>(2), B<timespec>(3), "
1022 "B<epoll>(7), B<time>(7)"
1023 msgstr ""
1024
1025 #. type: TH
1026 #: debian-trixie
1027 #, no-wrap
1028 msgid "2024-06-15"
1029 msgstr ""
1030
1031 #. type: TH
1032 #: debian-trixie
1033 #, no-wrap
1034 msgid "Linux man-pages 6.9.1"
1035 msgstr ""
1036
1037 #. type: Plain text
1038 #: debian-trixie
1039 msgid "Standard C library (I<libc>, I<-lc>)"
1040 msgstr ""
1041
1042 #. type: Plain text
1043 #: debian-trixie fedora-44 fedora-rawhide
1044 msgid "POSIX.1-2008."
1045 msgstr ""
1046
1047 #. FIXME .
1048 #. ppoll() is proposed for inclusion in POSIX:
1049 #. https://www.austingroupbugs.net/view.php?id=1263
1050 #. NetBSD 3.0 has a pollts() which is like Linux ppoll().
1051 #. type: Plain text
1052 #: debian-trixie fedora-44 fedora-rawhide
1053 msgid "Linux."
1054 msgstr ""
1055
1056 #. type: Plain text
1057 #: debian-trixie fedora-44 fedora-rawhide
1058 msgid "Linux 2.6.16, glibc 2.4."
1059 msgstr ""
1060
1061 #. type: Plain text
1062 #: debian-trixie fedora-44 fedora-rawhide
1063 #, no-wrap
1064 msgid ""
1065 "$ B<mkfifo myfifo>\n"
1066 "$ B<./poll_input myfifo>\n"
1067 msgstr ""
1068
1069 #. type: Plain text
1070 #: debian-trixie fedora-44 fedora-rawhide
1071 #, no-wrap
1072 msgid "$ B<echo aaaaabbbbbccccc E<gt> myfifo>\n"
1073 msgstr ""
1074
1075 #. type: Plain text
1076 #: debian-trixie fedora-44 fedora-rawhide
1077 #, no-wrap
1078 msgid ""
1079 "Opened \"myfifo\" on fd 3\n"
1080 "About to poll()\n"
1081 "Ready: 1\n"
1082 " fd=3; events: POLLIN POLLHUP\n"
1083 " read 10 bytes: aaaaabbbbb\n"
1084 "About to poll()\n"
1085 "Ready: 1\n"
1086 " fd=3; events: POLLIN POLLHUP\n"
1087 " read 6 bytes: ccccc\n"
1088 "\\&\n"
1089 "About to poll()\n"
1090 "Ready: 1\n"
1091 " fd=3; events: POLLHUP\n"
1092 " closing fd 3\n"
1093 "All file descriptors closed; bye\n"
1094 msgstr ""
1095
1096 #. type: Plain text
1097 #: debian-trixie fedora-44 fedora-rawhide
1098 #, no-wrap
1099 msgid ""
1100 "/* poll_input.c\n"
1101 "\\&\n"
1102 " Licensed under GNU General Public License v2 or later.\n"
1103 "*/\n"
1104 "#include E<lt>fcntl.hE<gt>\n"
1105 "#include E<lt>poll.hE<gt>\n"
1106 "#include E<lt>stdio.hE<gt>\n"
1107 "#include E<lt>stdlib.hE<gt>\n"
1108 "#include E<lt>sys/types.hE<gt>\n"
1109 "#include E<lt>unistd.hE<gt>\n"
1110 "\\&\n"
1111 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\[rs]\n"
1112 " } while (0)\n"
1113 "\\&\n"
1114 "int\n"
1115 "main(int argc, char *argv[])\n"
1116 "{\n"
1117 " int ready;\n"
1118 " char buf[10];\n"
1119 " nfds_t num_open_fds, nfds;\n"
1120 " ssize_t s;\n"
1121 " struct pollfd *pfds;\n"
1122 "\\&\n"
1123 " if (argc E<lt> 2) {\n"
1124 " fprintf(stderr, \"Usage: %s file...\\[rs]n\", argv[0]);\n"
1125 " exit(EXIT_FAILURE);\n"
1126 " }\n"
1127 "\\&\n"
1128 " num_open_fds = nfds = argc - 1;\n"
1129 " pfds = calloc(nfds, sizeof(struct pollfd));\n"
1130 " if (pfds == NULL)\n"
1131 " errExit(\"malloc\");\n"
1132 "\\&\n"
1133 " /* Open each file on command line, and add it to \\[aq]pfds\\[aq] array. */\n"
1134 "\\&\n"
1135 " for (nfds_t j = 0; j E<lt> nfds; j++) {\n"
1136 " pfds[j].fd = open(argv[j + 1], O_RDONLY);\n"
1137 " if (pfds[j].fd == -1)\n"
1138 " errExit(\"open\");\n"
1139 "\\&\n"
1140 " printf(\"Opened \\[rs]\"%s\\[rs]\" on fd %d\\[rs]n\", argv[j + 1], pfds[j].fd);\n"
1141 "\\&\n"
1142 " pfds[j].events = POLLIN;\n"
1143 " }\n"
1144 "\\&\n"
1145 " /* Keep calling poll() as long as at least one file descriptor is\n"
1146 " open. */\n"
1147 "\\&\n"
1148 " while (num_open_fds E<gt> 0) {\n"
1149 " printf(\"About to poll()\\[rs]n\");\n"
1150 " ready = poll(pfds, nfds, -1);\n"
1151 " if (ready == -1)\n"
1152 " errExit(\"poll\");\n"
1153 "\\&\n"
1154 " printf(\"Ready: %d\\[rs]n\", ready);\n"
1155 "\\&\n"
1156 " /* Deal with array returned by poll(). */\n"
1157 "\\&\n"
1158 " for (nfds_t j = 0; j E<lt> nfds; j++) {\n"
1159 " if (pfds[j].revents != 0) {\n"
1160 " printf(\" fd=%d; events: %s%s%s\\[rs]n\", pfds[j].fd,\n"
1161 " (pfds[j].revents & POLLIN) ? \"POLLIN \" : \"\",\n"
1162 " (pfds[j].revents & POLLHUP) ? \"POLLHUP \" : \"\",\n"
1163 " (pfds[j].revents & POLLERR) ? \"POLLERR \" : \"\");\n"
1164 "\\&\n"
1165 " if (pfds[j].revents & POLLIN) {\n"
1166 " s = read(pfds[j].fd, buf, sizeof(buf));\n"
1167 " if (s == -1)\n"
1168 " errExit(\"read\");\n"
1169 " printf(\" read %zd bytes: %.*s\\[rs]n\",\n"
1170 " s, (int) s, buf);\n"
1171 " } else { /* POLLERR | POLLHUP */\n"
1172 " printf(\" closing fd %d\\[rs]n\", pfds[j].fd);\n"
1173 " if (close(pfds[j].fd) == -1)\n"
1174 " errExit(\"close\");\n"
1175 " num_open_fds--;\n"
1176 " }\n"
1177 " }\n"
1178 " }\n"
1179 " }\n"
1180 "\\&\n"
1181 " printf(\"All file descriptors closed; bye\\[rs]n\");\n"
1182 " exit(EXIT_SUCCESS);\n"
1183 "}\n"
1184 msgstr ""
1185
1186 #. type: TH
1187 #: fedora-44 fedora-rawhide
1188 #, no-wrap
1189 msgid "2024-07-23"
1190 msgstr ""
1191
1192 #. type: TH
1193 #: fedora-44 fedora-rawhide
1194 #, no-wrap
1195 msgid "Linux man-pages 6.13"
1196 msgstr ""
1197
1198 #. type: TH
1199 #: mageia-cauldron
1200 #, no-wrap
1201 msgid "Linux man-pages 6.17"
1202 msgstr ""
1203
1204 #. type: TH
1205 #: opensuse-leap-16-1 opensuse-tumbleweed
1206 #, no-wrap
1207 msgid "Linux man-pages (unreleased)"
1208 msgstr ""