Debian Codegraph @

po/es/man7/epoll.7.po

raw
1 # Spanish translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 msgid ""
5 msgstr ""
6 "Project-Id-Version: manpages-l10n 4.11.0\n"
7 "POT-Creation-Date: 2026-06-05 06:23+0200\n"
8 "PO-Revision-Date: 2021-09-03 21:23+0200\n"
9 "Last-Translator: Automatically generated\n"
10 "Language-Team: Spanish <[email protected]>\n"
11 "Language: es\n"
12 "MIME-Version: 1.0\n"
13 "Content-Type: text/plain; charset=UTF-8\n"
14 "Content-Transfer-Encoding: 8bit\n"
15 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
17 #. type: TH
18 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
19 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
20 #, no-wrap
21 msgid "epoll"
22 msgstr ""
23
24 #. type: TH
25 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
26 #: opensuse-tumbleweed
27 #, no-wrap
28 msgid "2026-02-08"
29 msgstr "8 Febrero 2026"
30
31 #. type: TH
32 #: archlinux debian-unstable
33 #, fuzzy, no-wrap
34 #| msgid "Linux man-pages 6.17"
35 msgid "Linux man-pages 6.18"
36 msgstr "Páginas de Manual de Linux 6.17"
37
38 #. type: SH
39 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
40 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
41 #, no-wrap
42 msgid "NAME"
43 msgstr "NOMBRE"
44
45 #. type: Plain text
46 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
47 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
48 msgid "epoll - I/O event notification facility"
49 msgstr ""
50
51 #. type: SH
52 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
53 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
54 #, no-wrap
55 msgid "SYNOPSIS"
56 msgstr "SINOPSIS"
57
58 #. type: Plain text
59 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
60 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
61 #, no-wrap
62 msgid "B<#include E<lt>sys/epoll.hE<gt>>\n"
63 msgstr "B<#include E<lt>sys/epoll.hE<gt>>\n"
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 "DESCRIPTION"
70 msgstr "DESCRIPCIÓN"
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 msgid ""
76 "The B<epoll> API performs a similar task to B<poll>(2): monitoring multiple "
77 "file descriptors to see if I/O is possible on any of them. The B<epoll> API "
78 "can be used either as an edge-triggered or a level-triggered interface and "
79 "scales well to large numbers of watched file descriptors."
80 msgstr ""
81
82 #. type: Plain text
83 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
84 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
85 msgid ""
86 "The central concept of the B<epoll> API is the B<epoll> I<instance>, an in-"
87 "kernel data structure which, from a user-space perspective, can be "
88 "considered as a container for two lists:"
89 msgstr ""
90
91 #. type: IP
92 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
93 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
94 #, no-wrap
95 msgid "\\[bu]"
96 msgstr "\\[bu]"
97
98 #. type: Plain text
99 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
100 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
101 msgid ""
102 "The I<interest> list (sometimes also called the B<epoll> set): the set of "
103 "file descriptors that the process has registered an interest in monitoring."
104 msgstr ""
105
106 #. type: Plain text
107 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
108 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
109 msgid ""
110 "The I<ready> list: the set of file descriptors that are \"ready\" for I/O. "
111 "The ready list is a subset of (or, more precisely, a set of references to) "
112 "the file descriptors in the interest list. The ready list is dynamically "
113 "populated by the kernel as a result of I/O activity on those file "
114 "descriptors."
115 msgstr ""
116
117 #. type: Plain text
118 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
119 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
120 msgid ""
121 "The following system calls are provided to create and manage an B<epoll> "
122 "instance:"
123 msgstr ""
124
125 #. type: Plain text
126 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
127 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
128 msgid ""
129 "B<epoll_create>(2) creates a new B<epoll> instance and returns a file "
130 "descriptor referring to that instance. (The more recent "
131 "B<epoll_create1>(2) extends the functionality of B<epoll_create>(2).)"
132 msgstr ""
133
134 #. type: Plain text
135 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
136 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
137 msgid ""
138 "Interest in particular file descriptors is then registered via "
139 "B<epoll_ctl>(2), which adds items to the interest list of the B<epoll> "
140 "instance."
141 msgstr ""
142
143 #. type: Plain text
144 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
145 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
146 msgid ""
147 "B<epoll_wait>(2) waits for I/O events, blocking the calling thread if no "
148 "events are currently available. (This system call can be thought of as "
149 "fetching items from the ready list of the B<epoll> instance.)"
150 msgstr ""
151
152 #. type: SS
153 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
154 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
155 #, no-wrap
156 msgid "Level-triggered and edge-triggered"
157 msgstr ""
158
159 #. type: Plain text
160 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
161 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
162 msgid ""
163 "The B<epoll> event distribution interface is able to behave both as edge-"
164 "triggered (ET) and as level-triggered (LT). The difference between the two "
165 "mechanisms can be described as follows. Suppose that this scenario happens:"
166 msgstr ""
167
168 #. type: IP
169 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
170 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
171 #, no-wrap
172 msgid "(1)"
173 msgstr "(1)"
174
175 #. type: Plain text
176 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
177 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
178 msgid ""
179 "The file descriptor that represents the read side of a pipe (I<rfd>) is "
180 "registered on the B<epoll> instance."
181 msgstr ""
182
183 #. type: IP
184 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
185 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
186 #, no-wrap
187 msgid "(2)"
188 msgstr "(2)"
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 "A pipe writer writes 2\\ kB of data on the write side of the pipe."
194 msgstr ""
195
196 #. type: IP
197 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
198 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
199 #, no-wrap
200 msgid "(3)"
201 msgstr "(3)"
202
203 #. type: Plain text
204 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
205 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
206 msgid ""
207 "A call to B<epoll_wait>(2) is done that will return I<rfd> as a ready file "
208 "descriptor."
209 msgstr ""
210
211 #. type: IP
212 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
213 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
214 #, no-wrap
215 msgid "(4)"
216 msgstr "(4)"
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 pipe reader reads 1\\ kB of data from I<rfd>."
222 msgstr ""
223
224 #. type: IP
225 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
226 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
227 #, no-wrap
228 msgid "(5)"
229 msgstr "(5)"
230
231 #. type: Plain text
232 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
233 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
234 msgid "A call to B<epoll_wait>(2) is done."
235 msgstr ""
236
237 #. type: Plain text
238 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
239 #: opensuse-leap-16-1 opensuse-tumbleweed
240 msgid ""
241 "If the I<rfd> file descriptor has been added to the B<epoll> interface using "
242 "the B<EPOLLET> (edge-triggered) flag, the call to B<epoll_wait>(2) done in "
243 "step B<5> will probably hang despite the available data still present in the "
244 "file input buffer; meanwhile the remote peer might be expecting a response "
245 "based on the data it already sent. The reason for this is that edge-"
246 "triggered mode delivers events only when changes occur on the monitored file "
247 "descriptor, that is, an event will be generated upon each receipt of a chunk "
248 "of data. So, in step B<5> the caller might end up waiting for some data "
249 "that is already present inside the input buffer. In the above example, an "
250 "event on I<rfd> will be generated because of the write done in B<2> and the "
251 "event is consumed in B<3>. Since the read operation done in B<4> does not "
252 "consume the whole buffer data, the call to B<epoll_wait>(2) done in step "
253 "B<5> might block indefinitely."
254 msgstr ""
255
256 #. type: Plain text
257 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
258 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
259 msgid ""
260 "An application that employs the B<EPOLLET> flag should use nonblocking file "
261 "descriptors to avoid having a blocking read or write starve a task that is "
262 "handling multiple file descriptors. The suggested way to use B<epoll> as an "
263 "edge-triggered (B<EPOLLET>) interface is as follows:"
264 msgstr ""
265
266 #. type: Plain text
267 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
268 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
269 msgid "with nonblocking file descriptors; and"
270 msgstr ""
271
272 #. type: Plain text
273 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
274 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
275 msgid ""
276 "by waiting for an event only after B<read>(2) or B<write>(2) return "
277 "B<EAGAIN>."
278 msgstr ""
279
280 #. type: Plain text
281 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
282 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
283 msgid ""
284 "By contrast, when used as a level-triggered interface (the default, when "
285 "B<EPOLLET> is not specified), B<epoll> is simply a faster B<poll>(2), and "
286 "can be used wherever the latter is used since it shares the same semantics."
287 msgstr ""
288
289 #. type: Plain text
290 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
291 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
292 msgid ""
293 "Since even with edge-triggered B<epoll>, multiple events can be generated "
294 "upon receipt of multiple chunks of data, the caller has the option to "
295 "specify the B<EPOLLONESHOT> flag, to tell B<epoll> to disable the associated "
296 "file descriptor after the receipt of an event with B<epoll_wait>(2). When "
297 "the B<EPOLLONESHOT> flag is specified, it is the caller's responsibility to "
298 "rearm the file descriptor using B<epoll_ctl>(2) with B<EPOLL_CTL_MOD>."
299 msgstr ""
300
301 #. type: Plain text
302 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
303 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
304 msgid ""
305 "If multiple threads (or processes, if child processes have inherited the "
306 "B<epoll> file descriptor across B<fork>(2)) are blocked in "
307 "B<epoll_wait>(2) waiting on the same epoll file descriptor and a file "
308 "descriptor in the interest list that is marked for edge-triggered "
309 "(B<EPOLLET>) notification becomes ready, just one of the threads (or "
310 "processes) is awoken from B<epoll_wait>(2). This provides a useful "
311 "optimization for avoiding \"thundering herd\" wake-ups in some scenarios."
312 msgstr ""
313
314 #. type: SS
315 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
316 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
317 #, no-wrap
318 msgid "Interaction with autosleep"
319 msgstr ""
320
321 #. type: Plain text
322 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
323 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
324 msgid ""
325 "If the system is in B<autosleep> mode via I</sys/power/autosleep> and an "
326 "event happens which wakes the device from sleep, the device driver will keep "
327 "the device awake only until that event is queued. To keep the device awake "
328 "until the event has been processed, it is necessary to use the "
329 "B<epoll_ctl>(2) B<EPOLLWAKEUP> flag."
330 msgstr ""
331
332 #. type: Plain text
333 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
334 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
335 msgid ""
336 "When the B<EPOLLWAKEUP> flag is set in the B<events> field for a I<struct "
337 "epoll_event>, the system will be kept awake from the moment the event is "
338 "queued, through the B<epoll_wait>(2) call which returns the event until the "
339 "subsequent B<epoll_wait>(2) call. If the event should keep the system "
340 "awake beyond that time, then a separate I<wake_lock> should be taken before "
341 "the second B<epoll_wait>(2) call."
342 msgstr ""
343
344 #. type: SS
345 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
346 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
347 #, no-wrap
348 msgid "/proc interfaces"
349 msgstr "Interfaces /proc"
350
351 #. Following was added in Linux 2.6.28, but them removed in Linux 2.6.29
352 #. .TP
353 #. .IR /proc/sys/fs/epoll/max_user_instances " (since Linux 2.6.28)"
354 #. This specifies an upper limit on the number of epoll instances
355 #. that can be created per real user ID.
356 #. type: Plain text
357 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
358 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
359 msgid ""
360 "The following interfaces can be used to limit the amount of kernel memory "
361 "consumed by epoll:"
362 msgstr ""
363
364 #. type: TP
365 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
366 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
367 #, no-wrap
368 msgid "I</proc/sys/fs/epoll/max_user_watches> (since Linux 2.6.28)"
369 msgstr ""
370
371 #. Linux 2.6.29 (in Linux 2.6.28, the default was 1/32 of lowmem)
372 #. type: Plain text
373 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
374 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
375 msgid ""
376 "This specifies a limit on the total number of file descriptors that a user "
377 "can register across all epoll instances on the system. The limit is per "
378 "real user ID. Each registered file descriptor costs roughly 90 bytes on a "
379 "32-bit kernel, and roughly 160 bytes on a 64-bit kernel. Currently, the "
380 "default value for I<max_user_watches> is 1/25 (4%) of the available low "
381 "memory, divided by the registration cost in bytes."
382 msgstr ""
383
384 #. type: SS
385 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
386 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
387 #, no-wrap
388 msgid "Example for suggested usage"
389 msgstr ""
390
391 #. type: Plain text
392 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
393 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
394 msgid ""
395 "While the usage of B<epoll> when employed as a level-triggered interface "
396 "does have the same semantics as B<poll>(2), the edge-triggered usage "
397 "requires more clarification to avoid stalls in the application event loop. "
398 "In this example, listener is a nonblocking socket on which B<listen>(2) has "
399 "been called. The function I<do_use_fd()> uses the new ready file descriptor "
400 "until B<EAGAIN> is returned by either B<read>(2) or B<write>(2). An event-"
401 "driven state machine application should, after having received B<EAGAIN>, "
402 "record its current state so that at the next call to I<do_use_fd()> it will "
403 "continue to B<read>(2) or B<write>(2) from where it stopped before."
404 msgstr ""
405
406 #. type: Plain text
407 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
408 #: opensuse-tumbleweed
409 #, no-wrap
410 msgid ""
411 "#define MAX_EVENTS 10\n"
412 "struct epoll_event ev, events[MAX_EVENTS];\n"
413 "int listen_sock, conn_sock, nfds, epollfd;\n"
414 "\\&\n"
415 "/* Code to set up listening socket, \\[aq]listen_sock\\[aq],\n"
416 " (socket(), bind(), listen()) omitted. */\n"
417 "\\&\n"
418 "epollfd = epoll_create1(0);\n"
419 "if (epollfd == -1) {\n"
420 " perror(\"epoll_create1\");\n"
421 " exit(EXIT_FAILURE);\n"
422 "}\n"
423 "\\&\n"
424 "ev.events = EPOLLIN;\n"
425 "ev.data.fd = listen_sock;\n"
426 "if (epoll_ctl(epollfd, EPOLL_CTL_ADD, listen_sock, &ev) == -1) {\n"
427 " perror(\"epoll_ctl: listen_sock\");\n"
428 " exit(EXIT_FAILURE);\n"
429 "}\n"
430 "\\&\n"
431 "for (;;) {\n"
432 " nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);\n"
433 " if (nfds == -1) {\n"
434 " perror(\"epoll_wait\");\n"
435 " exit(EXIT_FAILURE);\n"
436 " }\n"
437 "\\&\n"
438 " for (n = 0; n E<lt> nfds; ++n) {\n"
439 " if (events[n].data.fd == listen_sock) {\n"
440 " conn_sock = accept(listen_sock,\n"
441 " (struct sockaddr *) &addr, &addrlen);\n"
442 " if (conn_sock == -1) {\n"
443 " perror(\"accept\");\n"
444 " exit(EXIT_FAILURE);\n"
445 " }\n"
446 " setnonblocking(conn_sock);\n"
447 " ev.events = EPOLLIN | EPOLLET;\n"
448 " ev.data.fd = conn_sock;\n"
449 " if (epoll_ctl(epollfd, EPOLL_CTL_ADD, conn_sock,\n"
450 " &ev) == -1) {\n"
451 " perror(\"epoll_ctl: conn_sock\");\n"
452 " exit(EXIT_FAILURE);\n"
453 " }\n"
454 " } else {\n"
455 " do_use_fd(events[n].data.fd);\n"
456 " }\n"
457 " }\n"
458 "}\n"
459 msgstr ""
460
461 #. type: Plain text
462 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
463 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
464 msgid ""
465 "When used as an edge-triggered interface, for performance reasons, it is "
466 "possible to add the file descriptor inside the B<epoll> interface "
467 "(B<EPOLL_CTL_ADD>) once by specifying (B<EPOLLIN>|B<EPOLLOUT>). This "
468 "allows you to avoid continuously switching between B<EPOLLIN> and "
469 "B<EPOLLOUT> calling B<epoll_ctl>(2) with B<EPOLL_CTL_MOD>."
470 msgstr ""
471
472 #. type: SS
473 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
474 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
475 #, no-wrap
476 msgid "Questions and answers"
477 msgstr ""
478
479 #. type: Plain text
480 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
481 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
482 msgid ""
483 "What is the key used to distinguish the file descriptors registered in an "
484 "interest list?"
485 msgstr ""
486
487 #. type: Plain text
488 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
489 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
490 msgid ""
491 "The key is the combination of the file descriptor number and the open file "
492 "description (also known as an \"open file handle\", the kernel's internal "
493 "representation of an open file)."
494 msgstr ""
495
496 #. type: Plain text
497 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
498 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
499 msgid ""
500 "What happens if you register the same file descriptor on an B<epoll> "
501 "instance twice?"
502 msgstr ""
503
504 #
505 #
506 #. But a file descriptor duplicated by fork(2) can't be added to the
507 #. set, because the [file *, fd] pair is already in the epoll set.
508 #. That is a somewhat ugly inconsistency. On the one hand, a child process
509 #. cannot add the duplicate file descriptor to the epoll set. (In every
510 #. other case that I can think of, file descriptors duplicated by fork have
511 #. similar semantics to file descriptors duplicated by dup() and friends.) On
512 #. the other hand, the very fact that the child has a duplicate of the
513 #. file descriptor means that even if the parent closes its file descriptor,
514 #. then epoll_wait() in the parent will continue to receive notifications for
515 #. that file descriptor because of the duplicated file descriptor in the child.
516 #. See http://thread.gmane.org/gmane.linux.kernel/596462/
517 #. "epoll design problems with common fork/exec patterns"
518 #. mtk, Feb 2008
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 "You will probably get B<EEXIST>. However, it is possible to add a duplicate "
524 "(B<dup>(2), B<dup2>(2), B<fcntl>(2) B<F_DUPFD>) file descriptor to the "
525 "same B<epoll> instance. This can be a useful technique for filtering "
526 "events, if the duplicate file descriptors are registered with different "
527 "I<events> masks."
528 msgstr ""
529
530 #. type: Plain text
531 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
532 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
533 msgid ""
534 "Can two B<epoll> instances wait for the same file descriptor? If so, are "
535 "events reported to both B<epoll> file descriptors?"
536 msgstr ""
537
538 #. type: Plain text
539 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
540 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
541 msgid ""
542 "Yes, and events would be reported to both. However, careful programming may "
543 "be needed to do this correctly."
544 msgstr ""
545
546 #. type: Plain text
547 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
548 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
549 msgid "Is the B<epoll> file descriptor itself poll/epoll/selectable?"
550 msgstr ""
551
552 #. type: Plain text
553 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
554 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
555 msgid ""
556 "Yes. If an B<epoll> file descriptor has events waiting, then it will "
557 "indicate as being readable."
558 msgstr ""
559
560 #. type: Plain text
561 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
562 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
563 msgid ""
564 "What happens if one attempts to put an B<epoll> file descriptor into its own "
565 "file descriptor set?"
566 msgstr ""
567
568 #. type: Plain text
569 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
570 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
571 msgid ""
572 "The B<epoll_ctl>(2) call fails (B<EINVAL>). However, you can add an "
573 "B<epoll> file descriptor inside another B<epoll> file descriptor set."
574 msgstr ""
575
576 #. type: Plain text
577 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
578 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
579 msgid ""
580 "Can I send an B<epoll> file descriptor over a UNIX domain socket to another "
581 "process?"
582 msgstr ""
583
584 #. type: Plain text
585 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
586 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
587 msgid ""
588 "Yes, but it does not make sense to do this, since the receiving process "
589 "would not have copies of the file descriptors in the interest list."
590 msgstr ""
591
592 #. type: Plain text
593 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
594 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
595 msgid ""
596 "Will closing a file descriptor cause it to be removed from all B<epoll> "
597 "interest lists?"
598 msgstr ""
599
600 #. type: Plain text
601 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
602 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
603 msgid ""
604 "Yes, but be aware of the following point. A file descriptor is a reference "
605 "to an open file description (see B<open>(2)). Whenever a file descriptor is "
606 "duplicated via B<dup>(2), B<dup2>(2), B<fcntl>(2) B<F_DUPFD>, or "
607 "B<fork>(2), a new file descriptor referring to the same open file "
608 "description is created. An open file description continues to exist until "
609 "all file descriptors referring to it have been closed."
610 msgstr ""
611
612 #. type: Plain text
613 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
614 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
615 msgid ""
616 "A file descriptor is removed from an interest list only after all the file "
617 "descriptors referring to the underlying open file description have been "
618 "closed. This means that even after a file descriptor that is part of an "
619 "interest list has been closed, events may be reported for that file "
620 "descriptor if other file descriptors referring to the same underlying file "
621 "description remain open. To prevent this happening, the file descriptor "
622 "must be explicitly removed from the interest list (using B<epoll_ctl>(2) "
623 "B<EPOLL_CTL_DEL>) before it is duplicated. Alternatively, the application "
624 "must ensure that all file descriptors are closed (which may be difficult if "
625 "file descriptors were duplicated behind the scenes by library functions that "
626 "used B<dup>(2) or B<fork>(2))."
627 msgstr ""
628
629 #. type: Plain text
630 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
631 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
632 msgid ""
633 "If more than one event occurs between B<epoll_wait>(2) calls, are they "
634 "combined or reported separately?"
635 msgstr ""
636
637 #. type: Plain text
638 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
639 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
640 msgid "They will be combined."
641 msgstr ""
642
643 #. type: Plain text
644 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
645 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
646 msgid ""
647 "Does an operation on a file descriptor affect the already collected but not "
648 "yet reported events?"
649 msgstr ""
650
651 #. type: Plain text
652 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
653 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
654 msgid ""
655 "You can do two operations on an existing file descriptor. Remove would be "
656 "meaningless for this case. Modify will reread available I/O."
657 msgstr ""
658
659 #. type: Plain text
660 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
661 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
662 msgid ""
663 "Do I need to continuously read/write a file descriptor until B<EAGAIN> when "
664 "using the B<EPOLLET> flag (edge-triggered behavior)?"
665 msgstr ""
666
667 #. type: Plain text
668 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
669 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
670 msgid ""
671 "Receiving an event from B<epoll_wait>(2) should suggest to you that such "
672 "file descriptor is ready for the requested I/O operation. You must consider "
673 "it ready until the next (nonblocking) read/write yields B<EAGAIN>. When "
674 "and how you will use the file descriptor is entirely up to you."
675 msgstr ""
676
677 #. type: Plain text
678 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
679 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
680 msgid ""
681 "For packet/token-oriented files (e.g., datagram socket, terminal in "
682 "canonical mode), the only way to detect the end of the read/write I/O space "
683 "is to continue to read/write until B<EAGAIN>."
684 msgstr ""
685
686 #. type: Plain text
687 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
688 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
689 msgid ""
690 "For stream-oriented files (e.g., pipe, FIFO, stream socket), the condition "
691 "that the read/write I/O space is exhausted can also be detected by checking "
692 "the amount of data read from / written to the target file descriptor. For "
693 "example, if you call B<read>(2) by asking to read a certain amount of data "
694 "and B<read>(2) returns a lower number of bytes, you can be sure of having "
695 "exhausted the read I/O space for the file descriptor. The same is true when "
696 "writing using B<write>(2). (Avoid this latter technique if you cannot "
697 "guarantee that the monitored file descriptor always refers to a stream-"
698 "oriented file.)"
699 msgstr ""
700
701 #. type: SS
702 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
703 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
704 #, no-wrap
705 msgid "Possible pitfalls and ways to avoid them"
706 msgstr ""
707
708 #. type: Plain text
709 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
710 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
711 msgid "B<Starvation (edge-triggered)>"
712 msgstr ""
713
714 #. type: Plain text
715 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
716 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
717 msgid ""
718 "If there is a large amount of I/O space, it is possible that by trying to "
719 "drain it the other files will not get processed causing starvation. (This "
720 "problem is not specific to B<epoll>.)"
721 msgstr ""
722
723 #. type: Plain text
724 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
725 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
726 msgid ""
727 "The solution is to maintain a ready list and mark the file descriptor as "
728 "ready in its associated data structure, thereby allowing the application to "
729 "remember which files need to be processed but still round robin amongst all "
730 "the ready files. This also supports ignoring subsequent events you receive "
731 "for file descriptors that are already ready."
732 msgstr ""
733
734 #. type: Plain text
735 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
736 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
737 msgid "B<If using an event cache...>"
738 msgstr ""
739
740 #. type: Plain text
741 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
742 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
743 msgid ""
744 "If you use an event cache or store all the file descriptors returned from "
745 "B<epoll_wait>(2), then make sure to provide a way to mark its closure "
746 "dynamically (i.e., caused by a previous event's processing). Suppose you "
747 "receive 100 events from B<epoll_wait>(2), and in event #47 a condition "
748 "causes event #13 to be closed. If you remove the structure and B<close>(2) "
749 "the file descriptor for event #13, then your event cache might still say "
750 "there are events waiting for that file descriptor causing confusion."
751 msgstr ""
752
753 #. type: Plain text
754 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
755 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
756 msgid ""
757 "One solution for this is to call, during the processing of event 47, "
758 "B<epoll_ctl>(B<EPOLL_CTL_DEL>) to delete file descriptor 13 and "
759 "B<close>(2), then mark its associated data structure as removed and link it "
760 "to a cleanup list. If you find another event for file descriptor 13 in your "
761 "batch processing, you will discover the file descriptor had been previously "
762 "removed and there will be no confusion."
763 msgstr ""
764
765 #. type: SH
766 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
767 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
768 #, no-wrap
769 msgid "VERSIONS"
770 msgstr "VERSIONES"
771
772 #. type: Plain text
773 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
774 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
775 msgid ""
776 "Some other systems provide similar mechanisms; for example, FreeBSD has "
777 "I<kqueue>, and Solaris has I</dev/poll>."
778 msgstr ""
779
780 #. type: SH
781 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
782 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
783 #, no-wrap
784 msgid "STANDARDS"
785 msgstr "ESTÁNDARES"
786
787 #. type: Plain text
788 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
789 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
790 msgid "Linux."
791 msgstr "Linux."
792
793 #. type: SH
794 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
795 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
796 #, no-wrap
797 msgid "HISTORY"
798 msgstr "HISTORIAL"
799
800 #. Its interface should be finalized in Linux 2.5.66.
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 "Linux 2.5.44. glibc 2.3.2."
805 msgstr ""
806
807 #. type: SH
808 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
809 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
810 #, no-wrap
811 msgid "NOTES"
812 msgstr "NOTAS"
813
814 #. type: Plain text
815 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
816 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
817 msgid ""
818 "The set of file descriptors that is being monitored via an epoll file "
819 "descriptor can be viewed via the entry for the epoll file descriptor in the "
820 "process's I</proc/>pidI</fdinfo> directory. See B<proc>(5) for further "
821 "details."
822 msgstr ""
823
824 #. type: Plain text
825 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
826 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
827 msgid ""
828 "The B<kcmp>(2) B<KCMP_EPOLL_TFD> operation can be used to test whether a "
829 "file descriptor is present in an epoll instance."
830 msgstr ""
831
832 #. type: SH
833 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
834 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
835 #, no-wrap
836 msgid "SEE ALSO"
837 msgstr "VÉASE TAMBIÉN"
838
839 #. type: Plain text
840 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
841 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
842 msgid ""
843 "B<epoll_create>(2), B<epoll_create1>(2), B<epoll_ctl>(2), B<epoll_wait>(2), "
844 "B<ioctl_eventpoll>(2), B<poll>(2), B<select>(2)"
845 msgstr ""
846
847 #. type: TH
848 #: debian-trixie
849 #, no-wrap
850 msgid "2024-06-12"
851 msgstr "12 Junio 2024"
852
853 #. type: TH
854 #: debian-trixie
855 #, no-wrap
856 msgid "Linux man-pages 6.9.1"
857 msgstr "Páginas de Manual de Linux 6.9.1"
858
859 #. type: Plain text
860 #: debian-trixie
861 msgid ""
862 "If the I<rfd> file descriptor has been added to the B<epoll> interface using "
863 "the B<EPOLLET> (edge-triggered) flag, the call to B<epoll_wait>(2) done in "
864 "step B<5> will probably hang despite the available data still present in the "
865 "file input buffer; meanwhile the remote peer might be expecting a response "
866 "based on the data it already sent. The reason for this is that edge-"
867 "triggered mode delivers events only when changes occur on the monitored file "
868 "descriptor. So, in step B<5> the caller might end up waiting for some data "
869 "that is already present inside the input buffer. In the above example, an "
870 "event on I<rfd> will be generated because of the write done in B<2> and the "
871 "event is consumed in B<3>. Since the read operation done in B<4> does not "
872 "consume the whole buffer data, the call to B<epoll_wait>(2) done in step "
873 "B<5> might block indefinitely."
874 msgstr ""
875
876 #. type: Plain text
877 #: debian-trixie fedora-44 fedora-rawhide
878 #, no-wrap
879 msgid ""
880 "#define MAX_EVENTS 10\n"
881 "struct epoll_event ev, events[MAX_EVENTS];\n"
882 "int listen_sock, conn_sock, nfds, epollfd;\n"
883 "\\&\n"
884 "/* Code to set up listening socket, \\[aq]listen_sock\\[aq],\n"
885 " (socket(), bind(), listen()) omitted. */\n"
886 "\\&\n"
887 "epollfd = epoll_create1(0);\n"
888 "if (epollfd == -1) {\n"
889 " perror(\"epoll_create1\");\n"
890 " exit(EXIT_FAILURE);\n"
891 "}\n"
892 "\\&\n"
893 "ev.events = EPOLLIN;\n"
894 "ev.data.fd = listen_sock;\n"
895 "if (epoll_ctl(epollfd, EPOLL_CTL_ADD, listen_sock, &ev) == -1) {\n"
896 " perror(\"epoll_ctl: listen_sock\");\n"
897 " exit(EXIT_FAILURE);\n"
898 "}\n"
899 "\\&\n"
900 "for (;;) {\n"
901 " nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);\n"
902 " if (nfds == -1) {\n"
903 " perror(\"epoll_wait\");\n"
904 " exit(EXIT_FAILURE);\n"
905 " }\n"
906 "\\&\n"
907 " for (n = 0; n E<lt> nfds; ++n) {\n"
908 " if (events[n].data.fd == listen_sock) {\n"
909 " conn_sock = accept(listen_sock,\n"
910 " (struct sockaddr *) &addr, &addrlen);\n"
911 " if (conn_sock == -1) {\n"
912 " perror(\"accept\");\n"
913 " exit(EXIT_FAILURE);\n"
914 " }\n"
915 " setnonblocking(conn_sock);\n"
916 " ev.events = EPOLLIN | EPOLLET;\n"
917 " ev.data.fd = conn_sock;\n"
918 " if (epoll_ctl(epollfd, EPOLL_CTL_ADD, conn_sock,\n"
919 " &ev) == -1) {\n"
920 " perror(\"epoll_ctl: conn_sock\");\n"
921 " exit(EXIT_FAILURE);\n"
922 " }\n"
923 " } else {\n"
924 " do_use_fd(events[n].data.fd);\n"
925 " }\n"
926 " }\n"
927 "}\n"
928 msgstr ""
929
930 #. type: TH
931 #: fedora-44 fedora-rawhide
932 #, no-wrap
933 msgid "2024-08-21"
934 msgstr "21 Agosto 2024"
935
936 #. type: TH
937 #: fedora-44 fedora-rawhide
938 #, no-wrap
939 msgid "Linux man-pages 6.13"
940 msgstr "Páginas de Manual de Linux 6.13"
941
942 #. type: TH
943 #: mageia-cauldron
944 #, no-wrap
945 msgid "Linux man-pages 6.17"
946 msgstr "Páginas de Manual de Linux 6.17"
947
948 #. type: TH
949 #: opensuse-leap-16-1 opensuse-tumbleweed
950 #, no-wrap
951 msgid "Linux man-pages (unreleased)"
952 msgstr "Páginas de Manual de Linux (no publicadas)"