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.
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2015-01-21 20:35+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
20 #: build/C/man7/epoll.7:21
26 #: build/C/man7/epoll.7:21
32 #: build/C/man7/epoll.7:21 build/C/man2/epoll_create.2:24 build/C/man2/epoll_ctl.2:20 build/C/man2/epoll_wait.2:22 build/C/man2/poll.2:31
38 #: build/C/man7/epoll.7:21 build/C/man2/epoll_create.2:24 build/C/man2/epoll_ctl.2:20 build/C/man2/epoll_wait.2:22 build/C/man2/poll.2:31
40 msgid "Linux Programmer's Manual"
44 #: build/C/man7/epoll.7:22 build/C/man2/epoll_create.2:25 build/C/man2/epoll_ctl.2:21 build/C/man2/epoll_wait.2:23 build/C/man2/poll.2:32
50 #: build/C/man7/epoll.7:24
51 msgid "epoll - I/O event notification facility"
55 #: build/C/man7/epoll.7:24 build/C/man2/epoll_create.2:27 build/C/man2/epoll_ctl.2:23 build/C/man2/epoll_wait.2:25 build/C/man2/poll.2:34
61 #: build/C/man7/epoll.7:26 build/C/man2/epoll_ctl.2:25
62 msgid "B<#include E<lt>sys/epoll.hE<gt>>"
66 #: build/C/man7/epoll.7:26 build/C/man2/epoll_create.2:34 build/C/man2/epoll_ctl.2:28 build/C/man2/epoll_wait.2:35 build/C/man2/poll.2:47
72 #: build/C/man7/epoll.7:40
74 "The B<epoll> API performs a similar task to B<poll>(2): monitoring multiple "
75 "file descriptors to see if I/O is possible on any of them. The B<epoll> API "
76 "can be used either as an edge-triggered or a level-triggered interface and "
77 "scales well to large numbers of watched file descriptors. The following "
78 "system calls are provided to create and manage an B<epoll> instance:"
82 #: build/C/man7/epoll.7:40 build/C/man7/epoll.7:49 build/C/man7/epoll.7:57 build/C/man2/epoll_wait.2:59 build/C/man2/epoll_wait.2:61 build/C/man2/epoll_wait.2:63 build/C/man2/poll.2:134 build/C/man2/poll.2:136 build/C/man2/poll.2:138
88 #: build/C/man7/epoll.7:49
90 "B<epoll_create>(2) creates an B<epoll> instance and returns a file "
91 "descriptor referring to that instance. (The more recent B<epoll_create1>(2) "
92 "extends the functionality of B<epoll_create>(2).)"
96 #: build/C/man7/epoll.7:57
98 "Interest in particular file descriptors is then registered via "
99 "B<epoll_ctl>(2). The set of file descriptors currently registered on an "
100 "B<epoll> instance is sometimes called an I<epoll> set."
104 #: build/C/man7/epoll.7:61
106 "B<epoll_wait>(2) waits for I/O events, blocking the calling thread if no "
107 "events are currently available."
111 #: build/C/man7/epoll.7:61
113 msgid "Level-triggered and edge-triggered"
117 #: build/C/man7/epoll.7:70
119 "The B<epoll> event distribution interface is able to behave both as "
120 "edge-triggered (ET) and as level-triggered (LT). The difference between the "
121 "two mechanisms can be described as follows. Suppose that this scenario "
126 #: build/C/man7/epoll.7:70
132 #: build/C/man7/epoll.7:76
134 "The file descriptor that represents the read side of a pipe (I<rfd>) is "
135 "registered on the B<epoll> instance."
139 #: build/C/man7/epoll.7:76
145 #: build/C/man7/epoll.7:78
146 msgid "A pipe writer writes 2 kB of data on the write side of the pipe."
150 #: build/C/man7/epoll.7:78
156 #: build/C/man7/epoll.7:84
158 "A call to B<epoll_wait>(2) is done that will return I<rfd> as a ready file "
163 #: build/C/man7/epoll.7:84
169 #: build/C/man7/epoll.7:87
170 msgid "The pipe reader reads 1 kB of data from I<rfd>."
174 #: build/C/man7/epoll.7:87
180 #: build/C/man7/epoll.7:91
181 msgid "A call to B<epoll_wait>(2) is done."
185 #: build/C/man7/epoll.7:126
187 "If the I<rfd> file descriptor has been added to the B<epoll> interface using "
188 "the B<EPOLLET> (edge-triggered) flag, the call to B<epoll_wait>(2) done in "
189 "step B<5> will probably hang despite the available data still present in the "
190 "file input buffer; meanwhile the remote peer might be expecting a response "
191 "based on the data it already sent. The reason for this is that "
192 "edge-triggered mode delivers events only when changes occur on the monitored "
193 "file descriptor. So, in step B<5> the caller might end up waiting for some "
194 "data that is already present inside the input buffer. In the above example, "
195 "an event on I<rfd> will be generated because of the write done in B<2> and "
196 "the event is consumed in B<3>. Since the read operation done in B<4> does "
197 "not consume the whole buffer data, the call to B<epoll_wait>(2) done in "
198 "step B<5> might block indefinitely."
202 #: build/C/man7/epoll.7:136
204 "An application that employs the B<EPOLLET> flag should use nonblocking file "
205 "descriptors to avoid having a blocking read or write starve a task that is "
206 "handling multiple file descriptors. The suggested way to use B<epoll> as an "
207 "edge-triggered (B<EPOLLET>) interface is as follows:"
211 #: build/C/man7/epoll.7:137
217 #: build/C/man7/epoll.7:140
218 msgid "with nonblocking file descriptors; and"
222 #: build/C/man7/epoll.7:140
228 #: build/C/man7/epoll.7:148
230 "by waiting for an event only after B<read>(2) or B<write>(2) return "
235 #: build/C/man7/epoll.7:159
237 "By contrast, when used as a level-triggered interface (the default, when "
238 "B<EPOLLET> is not specified), B<epoll> is simply a faster B<poll>(2), and "
239 "can be used wherever the latter is used since it shares the same semantics."
243 #: build/C/man7/epoll.7:176
245 "Since even with edge-triggered B<epoll>, multiple events can be generated "
246 "upon receipt of multiple chunks of data, the caller has the option to "
247 "specify the B<EPOLLONESHOT> flag, to tell B<epoll> to disable the associated "
248 "file descriptor after the receipt of an event with B<epoll_wait>(2). When "
249 "the B<EPOLLONESHOT> flag is specified, it is the caller's responsibility to "
250 "rearm the file descriptor using B<epoll_ctl>(2) with B<EPOLL_CTL_MOD>."
254 #: build/C/man7/epoll.7:176
256 msgid "Interaction with autosleep"
260 #: build/C/man7/epoll.7:188
262 "If the system is in B<autosleep> mode via I</sys/power/autosleep> and an "
263 "event happens which wakes the device from sleep, the device driver will only "
264 "keep the device awake until that event is queued. To keep the device awake "
265 "until the event has been processed, it is necessary to use the B<epoll>(7) "
266 "B<EPOLLWAKEUP> flag."
270 #: build/C/man7/epoll.7:207
272 "When the B<EPOLLWAKEUP> flag is set in the B<events> field for a I<struct "
273 "epoll_event>, the system will be kept awake from the moment the event is "
274 "queued, through the B<epoll_wait>(2) call which returns the event until the "
275 "subsequent B<epoll_wait>(2) call. If the event should keep the system "
276 "awake beyond that time, then a separate I<wake_lock> should be taken before "
277 "the second B<epoll_wait>(2) call."
281 #: build/C/man7/epoll.7:207
283 msgid "/proc interfaces"
286 #. Following was added in 2.6.28, but them removed in 2.6.29
288 #. .IR /proc/sys/fs/epoll/max_user_instances " (since Linux 2.6.28)"
289 #. This specifies an upper limit on the number of epoll instances
290 #. that can be created per real user ID.
292 #: build/C/man7/epoll.7:215
294 "The following interfaces can be used to limit the amount of kernel memory "
299 #: build/C/man7/epoll.7:215
301 msgid "I</proc/sys/fs/epoll/max_user_watches> (since Linux 2.6.28)"
304 #. 2.6.29 (in 2.6.28, the default was 1/32 of lowmem)
306 #: build/C/man7/epoll.7:229
308 "This specifies a limit on the total number of file descriptors that a user "
309 "can register across all epoll instances on the system. The limit is per "
310 "real user ID. Each registered file descriptor costs roughly 90 bytes on a "
311 "32-bit kernel, and roughly 160 bytes on a 64-bit kernel. Currently, the "
312 "default value for I<max_user_watches> is 1/25 (4%) of the available low "
313 "memory, divided by the registration cost in bytes."
317 #: build/C/man7/epoll.7:229
319 msgid "Example for suggested usage"
323 #: build/C/man7/epoll.7:258
325 "While the usage of B<epoll> when employed as a level-triggered interface "
326 "does have the same semantics as B<poll>(2), the edge-triggered usage "
327 "requires more clarification to avoid stalls in the application event loop. "
328 "In this example, listener is a nonblocking socket on which B<listen>(2) has "
329 "been called. The function I<do_use_fd()> uses the new ready file descriptor "
330 "until B<EAGAIN> is returned by either B<read>(2) or B<write>(2). An "
331 "event-driven state machine application should, after having received "
332 "B<EAGAIN>, record its current state so that at the next call to "
333 "I<do_use_fd()> it will continue to B<read>(2) or B<write>(2) from where it "
338 #: build/C/man7/epoll.7:264
341 "#define MAX_EVENTS 10\n"
342 "struct epoll_event ev, events[MAX_EVENTS];\n"
343 "int listen_sock, conn_sock, nfds, epollfd;\n"
347 #: build/C/man7/epoll.7:267
350 "/* Code to set up listening socket, \\(aqlisten_sock\\(aq,\n"
351 " (socket(), bind(), listen()) omitted */\n"
355 #: build/C/man7/epoll.7:273
358 "epollfd = epoll_create1(0);\n"
359 "if (epollfd == -1) {\n"
360 " perror(\"epoll_create1\");\n"
361 " exit(EXIT_FAILURE);\n"
366 #: build/C/man7/epoll.7:280
369 "ev.events = EPOLLIN;\n"
370 "ev.data.fd = listen_sock;\n"
371 "if (epoll_ctl(epollfd, EPOLL_CTL_ADD, listen_sock, &ev) == -1) {\n"
372 " perror(\"epoll_ctl: listen_sock\");\n"
373 " exit(EXIT_FAILURE);\n"
378 #: build/C/man7/epoll.7:287
382 " nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);\n"
383 " if (nfds == -1) {\n"
384 " perror(\"epoll_pwait\");\n"
385 " exit(EXIT_FAILURE);\n"
390 #: build/C/man7/epoll.7:309
393 " for (n = 0; n E<lt> nfds; ++n) {\n"
394 " if (events[n].data.fd == listen_sock) {\n"
395 " conn_sock = accept(listen_sock,\n"
396 " (struct sockaddr *) &local, &addrlen);\n"
397 " if (conn_sock == -1) {\n"
398 " perror(\"accept\");\n"
399 " exit(EXIT_FAILURE);\n"
401 " setnonblocking(conn_sock);\n"
402 " ev.events = EPOLLIN | EPOLLET;\n"
403 " ev.data.fd = conn_sock;\n"
404 " if (epoll_ctl(epollfd, EPOLL_CTL_ADD, conn_sock,\n"
406 " perror(\"epoll_ctl: conn_sock\");\n"
407 " exit(EXIT_FAILURE);\n"
410 " do_use_fd(events[n].data.fd);\n"
417 #: build/C/man7/epoll.7:328
419 "When used as an edge-triggered interface, for performance reasons, it is "
420 "possible to add the file descriptor inside the B<epoll> interface "
421 "(B<EPOLL_CTL_ADD>) once by specifying (B<EPOLLIN>|B<EPOLLOUT>). This "
422 "allows you to avoid continuously switching between B<EPOLLIN> and "
423 "B<EPOLLOUT> calling B<epoll_ctl>(2) with B<EPOLL_CTL_MOD>."
427 #: build/C/man7/epoll.7:328
429 msgid "Questions and answers"
433 #: build/C/man7/epoll.7:329
439 #: build/C/man7/epoll.7:334
441 "What is the key used to distinguish the file descriptors registered in an "
446 #: build/C/man7/epoll.7:334
452 #: build/C/man7/epoll.7:340
454 "The key is the combination of the file descriptor number and the open file "
455 "description (also known as an \"open file handle\", the kernel's internal "
456 "representation of an open file)."
460 #: build/C/man7/epoll.7:340
466 #: build/C/man7/epoll.7:345
468 "What happens if you register the same file descriptor on an B<epoll> "
473 #: build/C/man7/epoll.7:345
478 #. But a descriptor duplicated by fork(2) can't be added to the
479 #. set, because the [file *, fd] pair is already in the epoll set.
480 #. That is a somewhat ugly inconsistency. On the one hand, a child process
481 #. cannot add the duplicate file descriptor to the epoll set. (In every
482 #. other case that I can think of, descriptors duplicated by fork have
483 #. similar semantics to descriptors duplicated by dup() and friends.) On
484 #. the other hand, the very fact that the child has a duplicate of the
485 #. descriptor means that even if the parent closes its descriptor, then
486 #. epoll_wait() in the parent will continue to receive notifications for
487 #. that descriptor because of the duplicated descriptor in the child.
489 #. See http://thread.gmane.org/gmane.linux.kernel/596462/
490 #. "epoll design problems with common fork/exec patterns"
494 #: build/C/man7/epoll.7:376
496 "You will probably get B<EEXIST>. However, it is possible to add a duplicate "
497 "(B<dup>(2), B<dup2>(2), B<fcntl>(2) B<F_DUPFD>) descriptor to the same "
498 "B<epoll> instance. This can be a useful technique for filtering events, if "
499 "the duplicate file descriptors are registered with different I<events> "
504 #: build/C/man7/epoll.7:376
510 #: build/C/man7/epoll.7:384
512 "Can two B<epoll> instances wait for the same file descriptor? If so, are "
513 "events reported to both B<epoll> file descriptors?"
517 #: build/C/man7/epoll.7:384
523 #: build/C/man7/epoll.7:388
525 "Yes, and events would be reported to both. However, careful programming may "
526 "be needed to do this correctly."
530 #: build/C/man7/epoll.7:388
536 #: build/C/man7/epoll.7:393
537 msgid "Is the B<epoll> file descriptor itself poll/epoll/selectable?"
541 #: build/C/man7/epoll.7:393
547 #: build/C/man7/epoll.7:400
549 "Yes. If an B<epoll> file descriptor has events waiting, then it will "
550 "indicate as being readable."
554 #: build/C/man7/epoll.7:400
560 #: build/C/man7/epoll.7:405
562 "What happens if one attempts to put an B<epoll> file descriptor into its own "
563 "file descriptor set?"
567 #: build/C/man7/epoll.7:405
573 #: build/C/man7/epoll.7:416
575 "The B<epoll_ctl>(2) call will fail (B<EINVAL>). However, you can add an "
576 "B<epoll> file descriptor inside another B<epoll> file descriptor set."
580 #: build/C/man7/epoll.7:416
586 #: build/C/man7/epoll.7:421
588 "Can I send an B<epoll> file descriptor over a UNIX domain socket to another "
593 #: build/C/man7/epoll.7:421
599 #: build/C/man7/epoll.7:427
601 "Yes, but it does not make sense to do this, since the receiving process "
602 "would not have copies of the file descriptors in the B<epoll> set."
606 #: build/C/man7/epoll.7:427
612 #: build/C/man7/epoll.7:432
614 "Will closing a file descriptor cause it to be removed from all B<epoll> sets "
619 #: build/C/man7/epoll.7:432
625 #: build/C/man7/epoll.7:460
627 "Yes, but be aware of the following point. A file descriptor is a reference "
628 "to an open file description (see B<open>(2)). Whenever a descriptor is "
629 "duplicated via B<dup>(2), B<dup2>(2), B<fcntl>(2) B<F_DUPFD>, or "
630 "B<fork>(2), a new file descriptor referring to the same open file "
631 "description is created. An open file description continues to exist until "
632 "all file descriptors referring to it have been closed. A file descriptor is "
633 "removed from an B<epoll> set only after all the file descriptors referring "
634 "to the underlying open file description have been closed (or before if the "
635 "descriptor is explicitly removed using B<epoll_ctl>(2) B<EPOLL_CTL_DEL>). "
636 "This means that even after a file descriptor that is part of an B<epoll> set "
637 "has been closed, events may be reported for that file descriptor if other "
638 "file descriptors referring to the same underlying file description remain "
643 #: build/C/man7/epoll.7:460
649 #: build/C/man7/epoll.7:465
651 "If more than one event occurs between B<epoll_wait>(2) calls, are they "
652 "combined or reported separately?"
656 #: build/C/man7/epoll.7:465
662 #: build/C/man7/epoll.7:468
663 msgid "They will be combined."
667 #: build/C/man7/epoll.7:468
673 #: build/C/man7/epoll.7:472
675 "Does an operation on a file descriptor affect the already collected but not "
676 "yet reported events?"
680 #: build/C/man7/epoll.7:472
686 #: build/C/man7/epoll.7:478
688 "You can do two operations on an existing file descriptor. Remove would be "
689 "meaningless for this case. Modify will reread available I/O."
693 #: build/C/man7/epoll.7:478
699 #: build/C/man7/epoll.7:486
701 "Do I need to continuously read/write a file descriptor until B<EAGAIN> when "
702 "using the B<EPOLLET> flag (edge-triggered behavior) ?"
706 #: build/C/man7/epoll.7:486
712 #: build/C/man7/epoll.7:496
714 "Receiving an event from B<epoll_wait>(2) should suggest to you that such "
715 "file descriptor is ready for the requested I/O operation. You must consider "
716 "it ready until the next (nonblocking) read/write yields B<EAGAIN>. When "
717 "and how you will use the file descriptor is entirely up to you."
721 #: build/C/man7/epoll.7:502
723 "For packet/token-oriented files (e.g., datagram socket, terminal in "
724 "canonical mode), the only way to detect the end of the read/write I/O space "
725 "is to continue to read/write until B<EAGAIN>."
729 #: build/C/man7/epoll.7:518
731 "For stream-oriented files (e.g., pipe, FIFO, stream socket), the condition "
732 "that the read/write I/O space is exhausted can also be detected by checking "
733 "the amount of data read from / written to the target file descriptor. For "
734 "example, if you call B<read>(2) by asking to read a certain amount of data "
735 "and B<read>(2) returns a lower number of bytes, you can be sure of having "
736 "exhausted the read I/O space for the file descriptor. The same is true when "
737 "writing using B<write>(2). (Avoid this latter technique if you cannot "
738 "guarantee that the monitored file descriptor always refers to a "
739 "stream-oriented file.)"
743 #: build/C/man7/epoll.7:518
745 msgid "Possible pitfalls and ways to avoid them"
749 #: build/C/man7/epoll.7:519
751 msgid "B<o Starvation (edge-triggered)>"
755 #: build/C/man7/epoll.7:527
757 "If there is a large amount of I/O space, it is possible that by trying to "
758 "drain it the other files will not get processed causing starvation. (This "
759 "problem is not specific to B<epoll>.)"
763 #: build/C/man7/epoll.7:535
765 "The solution is to maintain a ready list and mark the file descriptor as "
766 "ready in its associated data structure, thereby allowing the application to "
767 "remember which files need to be processed but still round robin amongst all "
768 "the ready files. This also supports ignoring subsequent events you receive "
769 "for file descriptors that are already ready."
773 #: build/C/man7/epoll.7:535
775 msgid "B<o If using an event cache...>"
779 #: build/C/man7/epoll.7:551
781 "If you use an event cache or store all the file descriptors returned from "
782 "B<epoll_wait>(2), then make sure to provide a way to mark its closure "
783 "dynamically (i.e., caused by a previous event's processing). Suppose you "
784 "receive 100 events from B<epoll_wait>(2), and in event #47 a condition "
785 "causes event #13 to be closed. If you remove the structure and B<close>(2) "
786 "the file descriptor for event #13, then your event cache might still say "
787 "there are events waiting for that file descriptor causing confusion."
791 #: build/C/man7/epoll.7:562
793 "One solution for this is to call, during the processing of event 47, "
794 "B<epoll_ctl>(B<EPOLL_CTL_DEL>) to delete file descriptor 13 and "
795 "B<close>(2), then mark its associated data structure as removed and link it "
796 "to a cleanup list. If you find another event for file descriptor 13 in your "
797 "batch processing, you will discover the file descriptor had been previously "
798 "removed and there will be no confusion."
802 #: build/C/man7/epoll.7:562 build/C/man2/epoll_create.2:108 build/C/man2/epoll_ctl.2:256 build/C/man2/epoll_wait.2:187 build/C/man2/poll.2:330
807 #. Its interface should be finalized in Linux kernel 2.5.66.
809 #: build/C/man7/epoll.7:568
811 "The B<epoll> API was introduced in Linux kernel 2.5.44. Support was added "
812 "to glibc in version 2.3.2."
816 #: build/C/man7/epoll.7:568 build/C/man2/epoll_create.2:118 build/C/man2/epoll_ctl.2:261 build/C/man2/epoll_wait.2:197 build/C/man2/poll.2:347
818 msgid "CONFORMING TO"
822 #: build/C/man7/epoll.7:577
824 "The B<epoll> API is Linux-specific. Some other systems provide similar "
825 "mechanisms, for example, FreeBSD has I<kqueue>, and Solaris has "
830 #: build/C/man7/epoll.7:577 build/C/man2/epoll_create.2:144 build/C/man2/epoll_ctl.2:311 build/C/man2/epoll_wait.2:242 build/C/man2/poll.2:397
836 #: build/C/man7/epoll.7:581
837 msgid "B<epoll_create>(2), B<epoll_create1>(2), B<epoll_ctl>(2), B<epoll_wait>(2)"
841 #: build/C/man2/epoll_create.2:24
847 #: build/C/man2/epoll_create.2:24
853 #: build/C/man2/epoll_create.2:27
854 msgid "epoll_create, epoll_create1 - open an epoll file descriptor"
858 #: build/C/man2/epoll_create.2:30 build/C/man2/epoll_wait.2:28
860 msgid "B<#include E<lt>sys/epoll.hE<gt>>\n"
864 #: build/C/man2/epoll_create.2:33
867 "B<int epoll_create(int >I<size>B<);>\n"
868 "B<int epoll_create1(int >I<flags>B<);>\n"
872 #: build/C/man2/epoll_create.2:42
874 "B<epoll_create>() creates an B<epoll>(7) instance. Since Linux 2.6.8, the "
875 "I<size> argument is ignored, but must be greater than zero; see NOTES below."
879 #: build/C/man2/epoll_create.2:55
881 "B<epoll_create>() returns a file descriptor referring to the new epoll "
882 "instance. This file descriptor is used for all the subsequent calls to the "
883 "B<epoll> interface. When no longer required, the file descriptor returned "
884 "by B<epoll_create>() should be closed by using B<close>(2). When all file "
885 "descriptors referring to an epoll instance have been closed, the kernel "
886 "destroys the instance and releases the associated resources for reuse."
890 #: build/C/man2/epoll_create.2:55
892 msgid "epoll_create1()"
896 #: build/C/man2/epoll_create.2:67
898 "If I<flags> is 0, then, other than the fact that the obsolete I<size> "
899 "argument is dropped, B<epoll_create1>() is the same as B<epoll_create>(). "
900 "The following value can be included in I<flags> to obtain different "
905 #: build/C/man2/epoll_create.2:67
907 msgid "B<EPOLL_CLOEXEC>"
911 #: build/C/man2/epoll_create.2:77
913 "Set the close-on-exec (B<FD_CLOEXEC>) flag on the new file descriptor. See "
914 "the description of the B<O_CLOEXEC> flag in B<open>(2) for reasons why this "
919 #: build/C/man2/epoll_create.2:77 build/C/man2/epoll_ctl.2:185 build/C/man2/epoll_wait.2:150 build/C/man2/poll.2:301
925 #: build/C/man2/epoll_create.2:84
927 "On success, these system calls return a nonnegative file descriptor. On "
928 "error, -1 is returned, and I<errno> is set to indicate the error."
932 #: build/C/man2/epoll_create.2:84 build/C/man2/epoll_ctl.2:194 build/C/man2/epoll_wait.2:162 build/C/man2/poll.2:311
938 #: build/C/man2/epoll_create.2:85 build/C/man2/epoll_create.2:89 build/C/man2/epoll_ctl.2:209 build/C/man2/epoll_wait.2:179 build/C/man2/poll.2:320
944 #: build/C/man2/epoll_create.2:89
945 msgid "I<size> is not positive."
949 #: build/C/man2/epoll_create.2:94
950 msgid "(B<epoll_create1>()) Invalid value specified in I<flags>."
954 #: build/C/man2/epoll_create.2:94
960 #: build/C/man2/epoll_create.2:102
962 "The per-user limit on the number of epoll instances imposed by "
963 "I</proc/sys/fs/epoll/max_user_instances> was encountered. See B<epoll>(7) "
964 "for further details."
968 #: build/C/man2/epoll_create.2:102
974 #: build/C/man2/epoll_create.2:105
975 msgid "The system limit on the total number of open files has been reached."
979 #: build/C/man2/epoll_create.2:105 build/C/man2/epoll_ctl.2:232 build/C/man2/poll.2:327
985 #: build/C/man2/epoll_create.2:108
986 msgid "There was insufficient memory to create the kernel object."
990 #: build/C/man2/epoll_create.2:112
992 "B<epoll_create>() was added to the kernel in version 2.6. Library support "
993 "is provided in glibc starting with version 2.3.2."
996 #. To be precise: kernel 2.5.44.
997 #. The interface should be finalized by Linux kernel 2.5.66.
999 #: build/C/man2/epoll_create.2:118
1001 "B<epoll_create1>() was added to the kernel in version 2.6.27. Library "
1002 "support is provided in glibc starting with version 2.9."
1006 #: build/C/man2/epoll_create.2:121
1007 msgid "B<epoll_create>() is Linux-specific."
1011 #: build/C/man2/epoll_create.2:121 build/C/man2/epoll_ctl.2:265 build/C/man2/epoll_wait.2:200 build/C/man2/poll.2:353
1017 #: build/C/man2/epoll_create.2:144
1019 "In the initial B<epoll_create>() implementation, the I<size> argument "
1020 "informed the kernel of the number of file descriptors that the caller "
1021 "expected to add to the B<epoll> instance. The kernel used this information "
1022 "as a hint for the amount of space to initially allocate in internal data "
1023 "structures describing events. (If necessary, the kernel would allocate more "
1024 "space if the caller's usage exceeded the hint given in I<size>.) Nowadays, "
1025 "this hint is no longer required (the kernel dynamically sizes the required "
1026 "data structures without needing the hint), but I<size> must still be greater "
1027 "than zero, in order to ensure backward compatibility when new B<epoll> "
1028 "applications are run on older kernels."
1032 #: build/C/man2/epoll_create.2:148
1033 msgid "B<close>(2), B<epoll_ctl>(2), B<epoll_wait>(2), B<epoll>(7)"
1037 #: build/C/man2/epoll_ctl.2:20
1043 #: build/C/man2/epoll_ctl.2:20
1049 #: build/C/man2/epoll_ctl.2:23
1050 msgid "epoll_ctl - control interface for an epoll descriptor"
1054 #: build/C/man2/epoll_ctl.2:28
1056 "B<int epoll_ctl(int >I<epfd>B<, int >I<op>B<, int >I<fd>B<, struct "
1057 "epoll_event *>I<event>B<);>"
1061 #: build/C/man2/epoll_ctl.2:38
1063 "This system call performs control operations on the B<epoll>(7) instance "
1064 "referred to by the file descriptor I<epfd>. It requests that the operation "
1065 "I<op> be performed for the target file descriptor, I<fd>."
1069 #: build/C/man2/epoll_ctl.2:42
1070 msgid "Valid values for the I<op> argument are:"
1074 #: build/C/man2/epoll_ctl.2:42
1076 msgid "B<EPOLL_CTL_ADD>"
1080 #: build/C/man2/epoll_ctl.2:54
1082 "Register the target file descriptor I<fd> on the B<epoll> instance referred "
1083 "to by the file descriptor I<epfd> and associate the event I<event> with the "
1084 "internal file linked to I<fd>."
1088 #: build/C/man2/epoll_ctl.2:54
1090 msgid "B<EPOLL_CTL_MOD>"
1094 #: build/C/man2/epoll_ctl.2:60
1095 msgid "Change the event I<event> associated with the target file descriptor I<fd>."
1099 #: build/C/man2/epoll_ctl.2:60
1101 msgid "B<EPOLL_CTL_DEL>"
1105 #: build/C/man2/epoll_ctl.2:71
1107 "Remove (deregister) the target file descriptor I<fd> from the B<epoll> "
1108 "instance referred to by I<epfd>. The I<event> is ignored and can be NULL "
1109 "(but see BUGS below)."
1113 #: build/C/man2/epoll_ctl.2:79
1115 "The I<event> argument describes the object linked to the file descriptor "
1116 "I<fd>. The I<struct epoll_event> is defined as:"
1120 #: build/C/man2/epoll_ctl.2:88
1123 "typedef union epoll_data {\n"
1132 #: build/C/man2/epoll_ctl.2:93
1135 "struct epoll_event {\n"
1136 " uint32_t events; /* Epoll events */\n"
1137 " epoll_data_t data; /* User data variable */\n"
1142 #: build/C/man2/epoll_ctl.2:100
1144 "The I<events> member is a bit set composed using the following available "
1149 #: build/C/man2/epoll_ctl.2:100
1155 #: build/C/man2/epoll_ctl.2:105
1156 msgid "The associated file is available for B<read>(2) operations."
1160 #: build/C/man2/epoll_ctl.2:105
1166 #: build/C/man2/epoll_ctl.2:110
1167 msgid "The associated file is available for B<write>(2) operations."
1171 #: build/C/man2/epoll_ctl.2:110
1173 msgid "B<EPOLLRDHUP> (since Linux 2.6.17)"
1177 #: build/C/man2/epoll_ctl.2:116
1179 "Stream socket peer closed connection, or shut down writing half of "
1180 "connection. (This flag is especially useful for writing simple code to "
1181 "detect peer shutdown when using Edge Triggered monitoring.)"
1185 #: build/C/man2/epoll_ctl.2:116
1191 #: build/C/man2/epoll_ctl.2:121
1192 msgid "There is urgent data available for B<read>(2) operations."
1196 #: build/C/man2/epoll_ctl.2:121
1202 #: build/C/man2/epoll_ctl.2:127
1204 "Error condition happened on the associated file descriptor. "
1205 "B<epoll_wait>(2) will always wait for this event; it is not necessary to "
1206 "set it in I<events>."
1210 #: build/C/man2/epoll_ctl.2:127
1216 #: build/C/man2/epoll_ctl.2:133
1218 "Hang up happened on the associated file descriptor. B<epoll_wait>(2) will "
1219 "always wait for this event; it is not necessary to set it in I<events>."
1223 #: build/C/man2/epoll_ctl.2:133
1229 #: build/C/man2/epoll_ctl.2:143
1231 "Sets the Edge Triggered behavior for the associated file descriptor. The "
1232 "default behavior for B<epoll> is Level Triggered. See B<epoll>(7) for more "
1233 "detailed information about Edge and Level Triggered event distribution "
1238 #: build/C/man2/epoll_ctl.2:143
1240 msgid "B<EPOLLONESHOT> (since Linux 2.6.2)"
1244 #: build/C/man2/epoll_ctl.2:157
1246 "Sets the one-shot behavior for the associated file descriptor. This means "
1247 "that after an event is pulled out with B<epoll_wait>(2) the associated file "
1248 "descriptor is internally disabled and no other events will be reported by "
1249 "the B<epoll> interface. The user must call B<epoll_ctl>() with "
1250 "B<EPOLL_CTL_MOD> to rearm the file descriptor with a new event mask."
1254 #: build/C/man2/epoll_ctl.2:157
1256 msgid "B<EPOLLWAKEUP> (since Linux 3.5)"
1259 #. commit 4d7e30d98939a0340022ccd49325a3d70f7e0238
1261 #: build/C/man2/epoll_ctl.2:185
1263 "If B<EPOLLONESHOT> and B<EPOLLET> are clear and the process has the "
1264 "B<CAP_BLOCK_SUSPEND> capability, ensure that the system does not enter "
1265 "\"suspend\" or \"hibernate\" while this event is pending or being "
1266 "processed. The event is considered as being \"processed\" from the time "
1267 "when it is returned by a call to B<epoll_wait>(2) until the next call to "
1268 "B<epoll_wait>(2) on the same B<epoll>(7) file descriptor, the closure of "
1269 "that file descriptor, the removal of the event file descriptor with "
1270 "B<EPOLL_CTL_DEL>, or the clearing of B<EPOLLWAKEUP> for the event file "
1271 "descriptor with B<EPOLL_CTL_MOD>. See also BUGS."
1275 #: build/C/man2/epoll_ctl.2:194
1277 "When successful, B<epoll_ctl>() returns zero. When an error occurs, "
1278 "B<epoll_ctl>() returns -1 and I<errno> is set appropriately."
1282 #: build/C/man2/epoll_ctl.2:195 build/C/man2/epoll_wait.2:163
1288 #: build/C/man2/epoll_ctl.2:201
1289 msgid "I<epfd> or I<fd> is not a valid file descriptor."
1293 #: build/C/man2/epoll_ctl.2:201
1299 #: build/C/man2/epoll_ctl.2:209
1301 "I<op> was B<EPOLL_CTL_ADD>, and the supplied file descriptor I<fd> is "
1302 "already registered with this epoll instance."
1306 #: build/C/man2/epoll_ctl.2:222
1308 "I<epfd> is not an B<epoll> file descriptor, or I<fd> is the same as I<epfd>, "
1309 "or the requested operation I<op> is not supported by this interface."
1313 #: build/C/man2/epoll_ctl.2:222
1319 #: build/C/man2/epoll_ctl.2:232
1321 "I<op> was B<EPOLL_CTL_MOD> or B<EPOLL_CTL_DEL>, and I<fd> is not registered "
1322 "with this epoll instance."
1326 #: build/C/man2/epoll_ctl.2:237
1328 "There was insufficient memory to handle the requested I<op> control "
1333 #: build/C/man2/epoll_ctl.2:237
1339 #: build/C/man2/epoll_ctl.2:247
1341 "The limit imposed by I</proc/sys/fs/epoll/max_user_watches> was encountered "
1342 "while trying to register (B<EPOLL_CTL_ADD>) a new file descriptor on an "
1343 "epoll instance. See B<epoll>(7) for further details."
1347 #: build/C/man2/epoll_ctl.2:247
1353 #: build/C/man2/epoll_ctl.2:256
1355 "The target file I<fd> does not support B<epoll>. This error can occur if "
1356 "I<fd> refers to, for example, a regular file or a directory."
1359 #. To be precise: kernel 2.5.44.
1360 #. The interface should be finalized by Linux kernel 2.5.66.
1362 #: build/C/man2/epoll_ctl.2:261
1363 msgid "B<epoll_ctl>() was added to the kernel in version 2.6."
1367 #: build/C/man2/epoll_ctl.2:265
1369 "B<epoll_ctl>() is Linux-specific. Library support is provided in glibc "
1370 "starting with version 2.3.2."
1374 #: build/C/man2/epoll_ctl.2:270
1376 "The B<epoll> interface supports all file descriptors that support "
1381 #: build/C/man2/epoll_ctl.2:270 build/C/man2/epoll_wait.2:217 build/C/man2/poll.2:393
1387 #: build/C/man2/epoll_ctl.2:284
1389 "In kernel versions before 2.6.9, the B<EPOLL_CTL_DEL> operation required a "
1390 "non-null pointer in I<event>, even though this argument is ignored. Since "
1391 "Linux 2.6.9, I<event> can be specified as NULL when using B<EPOLL_CTL_DEL>. "
1392 "Applications that need to be portable to kernels before 2.6.9 should specify "
1393 "a non-null pointer in I<event>."
1396 #. commit a8159414d7e3af7233e7a5a82d1c5d85379bd75c (behavior change)
1397 #. https://lwn.net/Articles/520198/
1399 #: build/C/man2/epoll_ctl.2:311
1401 "If B<EPOLLWAKEUP> is specified in I<flags>, but the caller does not have the "
1402 "B<CAP_BLOCK_SUSPEND> capability, then the B<EPOLLWAKEUP> flag is I<silently "
1403 "ignored>. This unfortunate behavior is necessary because no validity checks "
1404 "were performed on the I<flags> argument in the original implementation, and "
1405 "the addition of the B<EPOLLWAKEUP> with a check that caused the call to fail "
1406 "if the caller did not have the B<CAP_BLOCK_SUSPEND> capability caused a "
1407 "breakage in at least one existing user-space application that happened to "
1408 "randomly (and uselessly) specify this bit. A robust application should "
1409 "therefore double check that it has the B<CAP_BLOCK_SUSPEND> capability if "
1410 "attempting to use the B<EPOLLWAKEUP> flag."
1414 #: build/C/man2/epoll_ctl.2:315
1415 msgid "B<epoll_create>(2), B<epoll_wait>(2), B<poll>(2), B<epoll>(7)"
1419 #: build/C/man2/epoll_wait.2:22
1425 #: build/C/man2/epoll_wait.2:22
1431 #: build/C/man2/epoll_wait.2:25
1432 msgid "epoll_wait, epoll_pwait - wait for an I/O event on an epoll file descriptor"
1436 #: build/C/man2/epoll_wait.2:34
1439 "B<int epoll_wait(int >I<epfd>B<, struct epoll_event *>I<events>B<,>\n"
1440 "B< int >I<maxevents>B<, int >I<timeout>B<);>\n"
1441 "B<int epoll_pwait(int >I<epfd>B<, struct epoll_event *>I<events>B<,>\n"
1442 "B< int >I<maxevents>B<, int >I<timeout>B<,>\n"
1443 "B< const sigset_t *>I<sigmask>B<);>\n"
1447 #: build/C/man2/epoll_wait.2:52
1449 "The B<epoll_wait>() system call waits for events on the B<epoll>(7) "
1450 "instance referred to by the file descriptor I<epfd>. The memory area "
1451 "pointed to by I<events> will contain the events that will be available for "
1452 "the caller. Up to I<maxevents> are returned by B<epoll_wait>(). The "
1453 "I<maxevents> argument must be greater than zero."
1457 #: build/C/man2/epoll_wait.2:59
1459 "The I<timeout> argument specifies the number of milliseconds that "
1460 "B<epoll_wait>() will block. The call will block until either:"
1464 #: build/C/man2/epoll_wait.2:61
1465 msgid "a file descriptor delivers an event;"
1469 #: build/C/man2/epoll_wait.2:63 build/C/man2/poll.2:138
1470 msgid "the call is interrupted by a signal handler; or"
1474 #: build/C/man2/epoll_wait.2:65 build/C/man2/poll.2:140
1475 msgid "the timeout expires."
1479 #: build/C/man2/epoll_wait.2:80
1481 "Note that the I<timeout> interval will be rounded up to the system clock "
1482 "granularity, and kernel scheduling delays mean that the blocking interval "
1483 "may overrun by a small amount. Specifying a I<timeout> of -1 causes "
1484 "B<epoll_wait>() to block indefinitely, while specifying a I<timeout> equal "
1485 "to zero cause B<epoll_wait>() to return immediately, even if no events are "
1490 #: build/C/man2/epoll_wait.2:84
1491 msgid "The I<struct epoll_event> is defined as:"
1495 #: build/C/man2/epoll_wait.2:93
1498 "typedef union epoll_data {\n"
1507 #: build/C/man2/epoll_wait.2:98
1510 "struct epoll_event {\n"
1511 " uint32_t events; /* Epoll events */\n"
1512 " epoll_data_t data; /* User data variable */\n"
1517 #: build/C/man2/epoll_wait.2:109
1519 "The I<data> of each returned structure will contain the same data the user "
1520 "set with an B<epoll_ctl>(2) (B<EPOLL_CTL_ADD>, B<EPOLL_CTL_MOD>) while the "
1521 "I<events> member will contain the returned event bit field."
1525 #: build/C/man2/epoll_wait.2:109
1527 msgid "epoll_pwait()"
1531 #: build/C/man2/epoll_wait.2:123
1533 "The relationship between B<epoll_wait>() and B<epoll_pwait>() is analogous "
1534 "to the relationship between B<select>(2) and B<pselect>(2): like "
1535 "B<pselect>(2), B<epoll_pwait>() allows an application to safely wait until "
1536 "either a file descriptor becomes ready or until a signal is caught."
1540 #: build/C/man2/epoll_wait.2:127
1541 msgid "The following B<epoll_pwait>() call:"
1545 #: build/C/man2/epoll_wait.2:130
1547 msgid " ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask);\n"
1551 #: build/C/man2/epoll_wait.2:135 build/C/man2/poll.2:250
1552 msgid "is equivalent to I<atomically> executing the following calls:"
1556 #: build/C/man2/epoll_wait.2:138
1558 msgid " sigset_t origmask;\n"
1562 #: build/C/man2/epoll_wait.2:142
1565 " sigprocmask(SIG_SETMASK, &sigmask, &origmask);\n"
1566 " ready = epoll_wait(epfd, &events, maxevents, timeout);\n"
1567 " sigprocmask(SIG_SETMASK, &origmask, NULL);\n"
1571 #: build/C/man2/epoll_wait.2:150
1573 "The I<sigmask> argument may be specified as NULL, in which case "
1574 "B<epoll_pwait>() is equivalent to B<epoll_wait>()."
1578 #: build/C/man2/epoll_wait.2:162
1580 "When successful, B<epoll_wait>() returns the number of file descriptors "
1581 "ready for the requested I/O, or zero if no file descriptor became ready "
1582 "during the requested I<timeout> milliseconds. When an error occurs, "
1583 "B<epoll_wait>() returns -1 and I<errno> is set appropriately."
1587 #: build/C/man2/epoll_wait.2:167
1588 msgid "I<epfd> is not a valid file descriptor."
1592 #: build/C/man2/epoll_wait.2:167 build/C/man2/poll.2:312
1598 #: build/C/man2/epoll_wait.2:172
1600 "The memory area pointed to by I<events> is not accessible with write "
1605 #: build/C/man2/epoll_wait.2:172 build/C/man2/poll.2:316
1611 #: build/C/man2/epoll_wait.2:179
1613 "The call was interrupted by a signal handler before either (1) any of the "
1614 "requested events occurred or (2) the I<timeout> expired; see B<signal>(7)."
1618 #: build/C/man2/epoll_wait.2:187
1620 "I<epfd> is not an B<epoll> file descriptor, or I<maxevents> is less than or "
1624 #. To be precise: kernel 2.5.44.
1625 #. The interface should be finalized by Linux kernel 2.5.66.
1627 #: build/C/man2/epoll_wait.2:193
1629 "B<epoll_wait>() was added to the kernel in version 2.6. Library support is "
1630 "provided in glibc starting with version 2.3.2."
1634 #: build/C/man2/epoll_wait.2:197
1636 "B<epoll_pwait>() was added to Linux in kernel 2.6.19. Library support is "
1637 "provided in glibc starting with version 2.6."
1641 #: build/C/man2/epoll_wait.2:200
1642 msgid "B<epoll_wait>() is Linux-specific."
1646 #: build/C/man2/epoll_wait.2:210
1648 "While one thread is blocked in a call to B<epoll_pwait>(), it is possible "
1649 "for another thread to add a file descriptor to the waited-upon B<epoll> "
1650 "instance. If the new file descriptor becomes ready, it will cause the "
1651 "B<epoll_wait>() call to unblock."
1655 #: build/C/man2/epoll_wait.2:217
1657 "For a discussion of what may happen if a file descriptor in an B<epoll> "
1658 "instance being monitored by B<epoll_wait>() is closed in another thread, "
1663 #: build/C/man2/epoll_wait.2:229
1665 "In kernels before 2.6.37, a I<timeout> value larger than approximately "
1666 "I<LONG_MAX / HZ> milliseconds is treated as -1 (i.e., infinity). Thus, for "
1667 "example, on a system where the I<sizeof(long)> is 4 and the kernel I<HZ> "
1668 "value is 1000, this means that timeouts greater than 35.79 minutes are "
1669 "treated as infinity."
1673 #: build/C/man2/epoll_wait.2:229 build/C/man2/poll.2:366
1675 msgid "C library/kernel ABI differences"
1679 #: build/C/man2/epoll_wait.2:242
1681 "The raw B<epoll_pwait>() system call has a sixth argument, I<size_t "
1682 "sigsetsize>, which specifies the size in bytes of the I<sigmask> argument. "
1683 "The glibc B<epoll_pwait>() wrapper function specifies this argument as a "
1684 "fixed value (equal to I<sizeof(sigset_t)>)."
1688 #: build/C/man2/epoll_wait.2:245
1689 msgid "B<epoll_create>(2), B<epoll_ctl>(2), B<epoll>(7)"
1693 #: build/C/man2/poll.2:31
1699 #: build/C/man2/poll.2:31
1705 #: build/C/man2/poll.2:34
1706 msgid "poll, ppoll - wait for some event on a file descriptor"
1710 #: build/C/man2/poll.2:37
1712 msgid "B<#include E<lt>poll.hE<gt>>\n"
1716 #: build/C/man2/poll.2:39
1719 "B<int poll(struct pollfd *>I<fds>B<, nfds_t >I<nfds>B<, int "
1720 ">I<timeout>B<);>\n"
1724 #: build/C/man2/poll.2:43
1727 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
1728 "B<#include E<lt>signal.hE<gt>>\n"
1729 "B<#include E<lt>poll.hE<gt>>\n"
1733 #: build/C/man2/poll.2:46
1736 "B<int ppoll(struct pollfd *>I<fds>B<, nfds_t >I<nfds>B<, >\n"
1737 "B< const struct timespec *>I<timeout_ts>B<, const sigset_t "
1738 "*>I<sigmask>B<);>\n"
1742 #: build/C/man2/poll.2:53
1744 "B<poll>() performs a similar task to B<select>(2): it waits for one of a "
1745 "set of file descriptors to become ready to perform I/O."
1749 #: build/C/man2/poll.2:57
1751 "The set of file descriptors to be monitored is specified in the I<fds> "
1752 "argument, which is an array of structures of the following form:"
1756 #: build/C/man2/poll.2:65
1760 " int fd; /* file descriptor */\n"
1761 " short events; /* requested events */\n"
1762 " short revents; /* returned events */\n"
1767 #: build/C/man2/poll.2:72
1769 "The caller should specify the number of items in the I<fds> array in "
1774 #: build/C/man2/poll.2:88
1776 "The field I<fd> contains a file descriptor for an open file. If this field "
1777 "is negative, then the corresponding I<events> field is ignored and the "
1778 "I<revents> field returns zero. (This provides an easy way of ignoring a "
1779 "file descriptor for a single B<poll>() call: simply negate the I<fd> "
1780 "field. Note, however, that this technique can't be used to ignore file "
1785 #: build/C/man2/poll.2:103
1787 "The field I<events> is an input parameter, a bit mask specifying the events "
1788 "the application is interested in for the file descriptor I<fd>. This field "
1789 "may be specified as zero, in which case the only events that can be returned "
1790 "in I<revents> are B<POLLHUP>, B<POLLERR>, and B<POLLNVAL> (see below)."
1794 #: build/C/man2/poll.2:122
1796 "The field I<revents> is an output parameter, filled by the kernel with the "
1797 "events that actually occurred. The bits returned in I<revents> can include "
1798 "any of those specified in I<events>, or one of the values B<POLLERR>, "
1799 "B<POLLHUP>, or B<POLLNVAL>. (These three bits are meaningless in the "
1800 "I<events> field, and will be set in the I<revents> field whenever the "
1801 "corresponding condition is true.)"
1805 #: build/C/man2/poll.2:127
1807 "If none of the events requested (and no error) has occurred for any of the "
1808 "file descriptors, then B<poll>() blocks until one of the events occurs."
1812 #: build/C/man2/poll.2:134
1814 "The I<timeout> argument specifies the number of milliseconds that B<poll>() "
1815 "should block waiting for a file descriptor to become ready. The call will "
1816 "block until either:"
1820 #: build/C/man2/poll.2:136
1821 msgid "a file descriptor becomes ready;"
1825 #: build/C/man2/poll.2:154
1827 "Note that the I<timeout> interval will be rounded up to the system clock "
1828 "granularity, and kernel scheduling delays mean that the blocking interval "
1829 "may overrun by a small amount. Specifying a negative value in I<timeout> "
1830 "means an infinite timeout. Specifying a I<timeout> of zero causes B<poll>() "
1831 "to return immediately, even if no file descriptors are ready."
1835 #: build/C/man2/poll.2:160
1837 "The bits that may be set/returned in I<events> and I<revents> are defined in "
1838 "I<E<lt>poll.hE<gt>>:"
1842 #: build/C/man2/poll.2:161
1848 #: build/C/man2/poll.2:164
1849 msgid "There is data to read."
1853 #: build/C/man2/poll.2:164
1859 #: build/C/man2/poll.2:168
1861 "There is urgent data to read (e.g., out-of-band data on TCP socket; "
1862 "pseudoterminal master in packet mode has seen state change in slave)."
1866 #: build/C/man2/poll.2:168
1872 #: build/C/man2/poll.2:174
1874 "Writing is now possible, though a write larger that the available space in a "
1875 "socket or pipe will still block (unless B<O_NONBLOCK> is set)."
1879 #: build/C/man2/poll.2:174
1881 msgid "B<POLLRDHUP> (since Linux 2.6.17)"
1885 #: build/C/man2/poll.2:185
1887 "Stream socket peer closed connection, or shut down writing half of "
1888 "connection. The B<_GNU_SOURCE> feature test macro must be defined (before "
1889 "including I<any> header files) in order to obtain this definition."
1893 #: build/C/man2/poll.2:185
1899 #: build/C/man2/poll.2:188
1900 msgid "Error condition (output only)."
1904 #: build/C/man2/poll.2:188
1910 #: build/C/man2/poll.2:191
1911 msgid "Hang up (output only)."
1915 #: build/C/man2/poll.2:191
1921 #: build/C/man2/poll.2:196
1922 msgid "Invalid request: I<fd> not open (output only)."
1926 #: build/C/man2/poll.2:202
1928 "When compiling with B<_XOPEN_SOURCE> defined, one also has the following, "
1929 "which convey no further information beyond the bits listed above:"
1933 #: build/C/man2/poll.2:203
1935 msgid "B<POLLRDNORM>"
1939 #: build/C/man2/poll.2:207
1940 msgid "Equivalent to B<POLLIN>."
1944 #: build/C/man2/poll.2:207
1946 msgid "B<POLLRDBAND>"
1949 #. POLLRDBAND is used in the DECnet protocol.
1951 #: build/C/man2/poll.2:211
1952 msgid "Priority band data can be read (generally unused on Linux)."
1956 #: build/C/man2/poll.2:211
1958 msgid "B<POLLWRNORM>"
1962 #: build/C/man2/poll.2:215
1963 msgid "Equivalent to B<POLLOUT>."
1967 #: build/C/man2/poll.2:215
1969 msgid "B<POLLWRBAND>"
1973 #: build/C/man2/poll.2:218
1974 msgid "Priority data may be written."
1978 #: build/C/man2/poll.2:222
1979 msgid "Linux also knows about, but does not use B<POLLMSG>."
1983 #: build/C/man2/poll.2:222
1989 #: build/C/man2/poll.2:236
1991 "The relationship between B<poll>() and B<ppoll>() is analogous to the "
1992 "relationship between B<select>(2) and B<pselect>(2): like B<pselect>(2), "
1993 "B<ppoll>() allows an application to safely wait until either a file "
1994 "descriptor becomes ready or until a signal is caught."
1998 #: build/C/man2/poll.2:242
2000 "Other than the difference in the precision of the I<timeout> argument, the "
2001 "following B<ppoll>() call:"
2005 #: build/C/man2/poll.2:245
2007 msgid " ready = ppoll(&fds, nfds, timeout_ts, &sigmask);\n"
2011 #: build/C/man2/poll.2:254
2014 " sigset_t origmask;\n"
2019 #: build/C/man2/poll.2:260
2022 " timeout = (timeout_ts == NULL) ? -1 :\n"
2023 " (timeout_ts.tv_sec * 1000 + timeout_ts.tv_nsec / 1000000);\n"
2024 " sigprocmask(SIG_SETMASK, &sigmask, &origmask);\n"
2025 " ready = poll(&fds, nfds, timeout);\n"
2026 " sigprocmask(SIG_SETMASK, &origmask, NULL);\n"
2030 #: build/C/man2/poll.2:267
2032 "See the description of B<pselect>(2) for an explanation of why B<ppoll>() "
2037 #: build/C/man2/poll.2:279
2039 "If the I<sigmask> argument is specified as NULL, then no signal mask "
2040 "manipulation is performed (and thus B<ppoll>() differs from B<poll>() only "
2041 "in the precision of the I<timeout> argument)."
2045 #: build/C/man2/poll.2:286
2047 "The I<timeout_ts> argument specifies an upper limit on the amount of time "
2048 "that B<ppoll>() will block. This argument is a pointer to a structure of "
2049 "the following form:"
2053 #: build/C/man2/poll.2:293
2056 "struct timespec {\n"
2057 " long tv_sec; /* seconds */\n"
2058 " long tv_nsec; /* nanoseconds */\n"
2063 #: build/C/man2/poll.2:301
2065 "If I<timeout_ts> is specified as NULL, then B<ppoll>() can block "
2070 #: build/C/man2/poll.2:311
2072 "On success, a positive number is returned; this is the number of structures "
2073 "which have nonzero I<revents> fields (in other words, those descriptors with "
2074 "events or errors reported). A value of 0 indicates that the call timed out "
2075 "and no file descriptors were ready. On error, -1 is returned, and I<errno> "
2076 "is set appropriately."
2080 #: build/C/man2/poll.2:316
2082 "The array given as argument was not contained in the calling program's "
2087 #: build/C/man2/poll.2:320
2088 msgid "A signal occurred before any requested event; see B<signal>(7)."
2092 #: build/C/man2/poll.2:327
2093 msgid "The I<nfds> value exceeds the B<RLIMIT_NOFILE> value."
2097 #: build/C/man2/poll.2:330
2098 msgid "There was no space to allocate file descriptor tables."
2101 #. library call was introduced in libc 5.4.28
2103 #: build/C/man2/poll.2:340
2105 "The B<poll>() system call was introduced in Linux 2.1.23. On older kernels "
2106 "that lack this system call, the glibc (and the old Linux libc) B<poll>() "
2107 "wrapper function provides emulation using B<select>(2)."
2111 #: build/C/man2/poll.2:347
2113 "The B<ppoll>() system call was added to Linux in kernel 2.6.16. The "
2114 "B<ppoll>() library call was added in glibc 2.4."
2117 #. NetBSD 3.0 has a pollts() which is like Linux ppoll().
2119 #: build/C/man2/poll.2:353
2120 msgid "B<poll>() conforms to POSIX.1-2001. B<ppoll>() is Linux-specific."
2124 #: build/C/man2/poll.2:361
2126 "Some implementations define the nonstandard constant B<INFTIM> with the "
2127 "value -1 for use as a I<timeout> for B<poll>(). This constant is not "
2128 "provided in glibc."
2132 #: build/C/man2/poll.2:366
2134 "For a discussion of what may happen if a file descriptor being monitored by "
2135 "B<poll>() is closed in another thread, see B<select>(2)."
2139 #: build/C/man2/poll.2:380
2141 "The Linux B<ppoll>() system call modifies its I<timeout_ts> argument. "
2142 "However, the glibc wrapper function hides this behavior by using a local "
2143 "variable for the timeout argument that is passed to the system call. Thus, "
2144 "the glibc B<ppoll>() function does not modify its I<timeout_ts> argument."
2148 #: build/C/man2/poll.2:393
2150 "The raw B<ppoll>() system call has a fifth argument, I<size_t sigsetsize>, "
2151 "which specifies the size in bytes of the I<sigmask> argument. The glibc "
2152 "B<ppoll>() wrapper function specifies this argument as a fixed value (equal "
2153 "to I<sizeof(sigset_t)>)."
2157 #: build/C/man2/poll.2:397
2159 "See the discussion of spurious readiness notifications under the BUGS "
2160 "section of B<select>(2)."
2164 #: build/C/man2/poll.2:401
2165 msgid "B<restart_syscall>(2), B<select>(2), B<select_tut>(2), B<time>(7)"