Debian Codegraph @

templates/man2/timerfd_create.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:49+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 "timerfd_create"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
28 #, no-wrap
29 msgid "2026-02-16"
30 msgstr ""
31
32 #. type: TH
33 #: archlinux debian-unstable
34 #, no-wrap
35 msgid "Linux man-pages 6.18"
36 msgstr ""
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 ""
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 ""
49 "timerfd_create, timerfd_settime, timerfd_gettime - timers that notify via "
50 "file descriptors"
51 msgstr ""
52
53 #. type: SH
54 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
55 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
56 #, no-wrap
57 msgid "LIBRARY"
58 msgstr ""
59
60 #. type: Plain text
61 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
62 #: opensuse-leap-16-1 opensuse-tumbleweed
63 msgid "Standard C library (I<libc>,\\ I<-lc>)"
64 msgstr ""
65
66 #. type: SH
67 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
68 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
69 #, no-wrap
70 msgid "SYNOPSIS"
71 msgstr ""
72
73 #. type: Plain text
74 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
75 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
76 #, no-wrap
77 msgid "B<#include E<lt>sys/timerfd.hE<gt>>\n"
78 msgstr ""
79
80 #. type: Plain text
81 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
82 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
83 #, no-wrap
84 msgid "B<int timerfd_create(int >I<clockid>B<, int >I<flags>B<);>\n"
85 msgstr ""
86
87 #. type: Plain text
88 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
89 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
90 #, no-wrap
91 msgid ""
92 "B<int timerfd_settime(int >I<fd>B<, int >I<flags>B<,>\n"
93 "B< const struct itimerspec *>I<new_value>B<,>\n"
94 "B< struct itimerspec *_Nullable >I<old_value>B<);>\n"
95 "B<int timerfd_gettime(int >I<fd>B<, struct itimerspec *>I<curr_value>B<);>\n"
96 msgstr ""
97
98 #. type: SH
99 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
100 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
101 #, no-wrap
102 msgid "DESCRIPTION"
103 msgstr ""
104
105 #. type: Plain text
106 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
107 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
108 msgid ""
109 "These system calls create and operate on a timer that delivers timer "
110 "expiration notifications via a file descriptor. They provide an alternative "
111 "to the use of B<setitimer>(2) or B<timer_create>(2), with the advantage "
112 "that the file descriptor may be monitored by B<select>(2), B<poll>(2), and "
113 "B<epoll>(7)."
114 msgstr ""
115
116 #. type: Plain text
117 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
118 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
119 msgid ""
120 "The use of these three system calls is analogous to the use of "
121 "B<timer_create>(2), B<timer_settime>(2), and B<timer_gettime>(2). (There is "
122 "no analog of B<timer_getoverrun>(2), since that functionality is provided by "
123 "B<read>(2), as described below.)"
124 msgstr ""
125
126 #. type: SS
127 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
128 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
129 #, no-wrap
130 msgid "timerfd_create()"
131 msgstr ""
132
133 #. type: Plain text
134 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
135 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
136 msgid ""
137 "B<timerfd_create>() creates a new timer object, and returns a file "
138 "descriptor that refers to that timer. The I<clockid> argument specifies the "
139 "clock that is used to mark the progress of the timer, and must be one of the "
140 "following:"
141 msgstr ""
142
143 #. type: TP
144 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
145 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
146 #, no-wrap
147 msgid "B<CLOCK_REALTIME>"
148 msgstr ""
149
150 #. type: Plain text
151 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
152 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
153 msgid "A settable system-wide real-time clock."
154 msgstr ""
155
156 #. type: TP
157 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
158 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
159 #, no-wrap
160 msgid "B<CLOCK_MONOTONIC>"
161 msgstr ""
162
163 #. type: Plain text
164 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
165 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
166 msgid ""
167 "A nonsettable monotonically increasing clock that measures time from some "
168 "unspecified point in the past that does not change after system startup."
169 msgstr ""
170
171 #. type: TP
172 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
173 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
174 #, no-wrap
175 msgid "B<CLOCK_BOOTTIME> (Since Linux 3.15)"
176 msgstr ""
177
178 #. commit 4a2378a943f09907fb1ae35c15de917f60289c14
179 #. type: Plain text
180 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
181 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
182 msgid ""
183 "Like B<CLOCK_MONOTONIC>, this is a monotonically increasing clock. However, "
184 "whereas the B<CLOCK_MONOTONIC> clock does not measure the time while a "
185 "system is suspended, the B<CLOCK_BOOTTIME> clock does include the time "
186 "during which the system is suspended. This is useful for applications that "
187 "need to be suspend-aware. B<CLOCK_REALTIME> is not suitable for such "
188 "applications, since that clock is affected by discontinuous changes to the "
189 "system clock."
190 msgstr ""
191
192 #. type: TP
193 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
194 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
195 #, no-wrap
196 msgid "B<CLOCK_REALTIME_ALARM> (since Linux 3.11)"
197 msgstr ""
198
199 #. commit 11ffa9d6065f344a9bd769a2452f26f2f671e5f8
200 #. type: Plain text
201 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
202 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
203 msgid ""
204 "This clock is like B<CLOCK_REALTIME>, but will wake the system if it is "
205 "suspended. The caller must have the B<CAP_WAKE_ALARM> capability in order "
206 "to set a timer against this clock."
207 msgstr ""
208
209 #. type: TP
210 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
211 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
212 #, no-wrap
213 msgid "B<CLOCK_BOOTTIME_ALARM> (since Linux 3.11)"
214 msgstr ""
215
216 #. commit 11ffa9d6065f344a9bd769a2452f26f2f671e5f8
217 #. type: Plain text
218 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
219 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
220 msgid ""
221 "This clock is like B<CLOCK_BOOTTIME>, but will wake the system if it is "
222 "suspended. The caller must have the B<CAP_WAKE_ALARM> capability in order "
223 "to set a timer against this clock."
224 msgstr ""
225
226 #. type: Plain text
227 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
228 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
229 msgid "See B<clock_getres>(2) for some further details on the above clocks."
230 msgstr ""
231
232 #. type: Plain text
233 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
234 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
235 msgid ""
236 "The current value of each of these clocks can be retrieved using "
237 "B<clock_gettime>(2)."
238 msgstr ""
239
240 #. type: Plain text
241 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
242 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
243 msgid ""
244 "Starting with Linux 2.6.27, the following values may be bitwise ORed in "
245 "I<flags> to change the behavior of B<timerfd_create>():"
246 msgstr ""
247
248 #. type: TP
249 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
250 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
251 #, no-wrap
252 msgid "B<TFD_NONBLOCK>"
253 msgstr ""
254
255 #. type: Plain text
256 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
257 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
258 msgid ""
259 "Set the B<O_NONBLOCK> file status flag on the open file description (see "
260 "B<open>(2)) referred to by the new file descriptor. Using this flag saves "
261 "extra calls to B<fcntl>(2) to achieve the same result."
262 msgstr ""
263
264 #. type: TP
265 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
266 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
267 #, no-wrap
268 msgid "B<TFD_CLOEXEC>"
269 msgstr ""
270
271 #. type: Plain text
272 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
273 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
274 msgid ""
275 "Set the close-on-exec (B<FD_CLOEXEC>) flag on the new file descriptor. See "
276 "the description of the B<O_CLOEXEC> flag in B<open>(2) for reasons why this "
277 "may be useful."
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 "In Linux versions up to and including 2.6.26, I<flags> must be specified as "
285 "zero."
286 msgstr ""
287
288 #. type: SS
289 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
290 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
291 #, no-wrap
292 msgid "timerfd_settime()"
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 ""
299 "B<timerfd_settime>() arms (starts) or disarms (stops) the timer referred "
300 "to by the file descriptor I<fd>."
301 msgstr ""
302
303 #. type: Plain text
304 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
305 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
306 msgid ""
307 "The I<new_value> argument specifies the initial expiration and interval for "
308 "the timer. The I<itimerspec> structure used for this argument is described "
309 "in B<itimerspec>(3type)."
310 msgstr ""
311
312 #. type: Plain text
313 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
314 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
315 msgid ""
316 "I<new_value.it_value> specifies the initial expiration of the timer, in "
317 "seconds and nanoseconds. Setting either field of I<new_value.it_value> to a "
318 "nonzero value arms the timer. Setting both fields of I<new_value.it_value> "
319 "to zero disarms the timer."
320 msgstr ""
321
322 #. type: Plain text
323 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
324 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
325 msgid ""
326 "Setting one or both fields of I<new_value.it_interval> to nonzero values "
327 "specifies the period, in seconds and nanoseconds, for repeated timer "
328 "expirations after the initial expiration. If both fields of "
329 "I<new_value.it_interval> are zero, the timer expires just once, at the time "
330 "specified by I<new_value.it_value>."
331 msgstr ""
332
333 #. type: Plain text
334 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
335 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
336 msgid ""
337 "By default, the initial expiration time specified in I<new_value> is "
338 "interpreted relative to the current time on the timer's clock at the time of "
339 "the call (i.e., I<new_value.it_value> specifies a time relative to the "
340 "current value of the clock specified by I<clockid>). An absolute timeout "
341 "can be selected via the I<flags> argument."
342 msgstr ""
343
344 #. type: Plain text
345 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
346 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
347 msgid ""
348 "The I<flags> argument is a bit mask that can include the following values:"
349 msgstr ""
350
351 #. type: TP
352 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
353 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
354 #, no-wrap
355 msgid "B<TFD_TIMER_ABSTIME>"
356 msgstr ""
357
358 #. type: Plain text
359 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
360 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
361 msgid ""
362 "Interpret I<new_value.it_value> as an absolute value on the timer's clock. "
363 "The timer will expire when the value of the timer's clock reaches the value "
364 "specified in I<new_value.it_value>."
365 msgstr ""
366
367 #. type: TP
368 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
369 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
370 #, no-wrap
371 msgid "B<TFD_TIMER_CANCEL_ON_SET>"
372 msgstr ""
373
374 #. type: Plain text
375 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
376 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
377 msgid ""
378 "If this flag is specified along with B<TFD_TIMER_ABSTIME> and the clock for "
379 "this timer is B<CLOCK_REALTIME> or B<CLOCK_REALTIME_ALARM>, then mark this "
380 "timer as cancelable if the real-time clock undergoes a discontinuous change "
381 "(B<settimeofday>(2), B<clock_settime>(2), or similar). When such changes "
382 "occur, a current or future B<read>(2) from the file descriptor will fail "
383 "with the error B<ECANCELED>."
384 msgstr ""
385
386 #. type: Plain text
387 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
388 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
389 msgid ""
390 "If the I<old_value> argument is not NULL, then the I<itimerspec> structure "
391 "that it points to is used to return the setting of the timer that was "
392 "current at the time of the call; see the description of "
393 "B<timerfd_gettime>() following."
394 msgstr ""
395
396 #. type: SS
397 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
398 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
399 #, no-wrap
400 msgid "timerfd_gettime()"
401 msgstr ""
402
403 #. type: Plain text
404 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
405 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
406 msgid ""
407 "B<timerfd_gettime>() returns, in I<curr_value>, an I<itimerspec> structure "
408 "that contains the current setting of the timer referred to by the file "
409 "descriptor I<fd>."
410 msgstr ""
411
412 #. type: Plain text
413 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
414 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
415 msgid ""
416 "The I<it_value> field returns the amount of time until the timer will next "
417 "expire. If both fields of this structure are zero, then the timer is "
418 "currently disarmed. This field always contains a relative value, regardless "
419 "of whether the B<TFD_TIMER_ABSTIME> flag was specified when setting the "
420 "timer."
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 ""
427 "The I<it_interval> field returns the interval of the timer. If both fields "
428 "of this structure are zero, then the timer is set to expire just once, at "
429 "the time specified by I<curr_value.it_value>."
430 msgstr ""
431
432 #. type: SS
433 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
434 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
435 #, no-wrap
436 msgid "Operating on a timer file descriptor"
437 msgstr ""
438
439 #. type: Plain text
440 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
441 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
442 msgid ""
443 "The file descriptor returned by B<timerfd_create>() supports the following "
444 "additional operations:"
445 msgstr ""
446
447 #. type: TP
448 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
449 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
450 #, no-wrap
451 msgid "B<read>(2)"
452 msgstr ""
453
454 #. type: Plain text
455 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
456 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
457 msgid ""
458 "If the timer has already expired one or more times since its settings were "
459 "last modified using B<timerfd_settime>(), or since the last successful "
460 "B<read>(2), then the buffer given to B<read>(2) returns an unsigned 8-byte "
461 "integer (I<uint64_t>) containing the number of expirations that have "
462 "occurred. (The returned value is in host byte order\\[em]that is, the "
463 "native byte order for integers on the host machine.)"
464 msgstr ""
465
466 #. type: Plain text
467 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
468 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
469 msgid ""
470 "If no timer expirations have occurred at the time of the B<read>(2), then "
471 "the call either blocks until the next timer expiration, or fails with the "
472 "error B<EAGAIN> if the file descriptor has been made nonblocking (via the "
473 "use of the B<fcntl>(2) B<F_SETFL> operation to set the B<O_NONBLOCK> flag)."
474 msgstr ""
475
476 #. type: Plain text
477 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
478 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
479 msgid ""
480 "A B<read>(2) fails with the error B<EINVAL> if the size of the supplied "
481 "buffer is less than 8 bytes."
482 msgstr ""
483
484 #. type: Plain text
485 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
486 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
487 msgid ""
488 "If the associated clock is either B<CLOCK_REALTIME> or "
489 "B<CLOCK_REALTIME_ALARM>, the timer is absolute (B<TFD_TIMER_ABSTIME>), and "
490 "the flag B<TFD_TIMER_CANCEL_ON_SET> was specified when calling "
491 "B<timerfd_settime>(), then B<read>(2) fails with the error B<ECANCELED> if "
492 "the real-time clock undergoes a discontinuous change. (This allows the "
493 "reading application to discover such discontinuous changes to the clock.)"
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 "If the associated clock is either B<CLOCK_REALTIME> or "
501 "B<CLOCK_REALTIME_ALARM>, the timer is absolute (B<TFD_TIMER_ABSTIME>), and "
502 "the flag B<TFD_TIMER_CANCEL_ON_SET> was I<not> specified when calling "
503 "B<timerfd_settime>(), then a discontinuous negative change to the clock "
504 "(e.g., B<clock_settime>(2)) may cause B<read>(2) to unblock, but return a "
505 "value of 0 (i.e., no bytes read), if the clock change occurs after the time "
506 "expired, but before the B<read>(2) on the file descriptor."
507 msgstr ""
508
509 #. type: TP
510 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
511 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
512 #, no-wrap
513 msgid "B<poll>(2)"
514 msgstr ""
515
516 #. type: TQ
517 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
518 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
519 #, no-wrap
520 msgid "B<select>(2)"
521 msgstr ""
522
523 #. type: TQ
524 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
525 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
526 #, no-wrap
527 msgid "(and similar)"
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 "The file descriptor is readable (the B<select>(2) I<readfds> argument; the "
535 "B<poll>(2) B<POLLIN> flag) if one or more timer expirations have occurred."
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 "The file descriptor also supports the other file-descriptor multiplexing "
543 "APIs: B<pselect>(2), B<ppoll>(2), and B<epoll>(7)."
544 msgstr ""
545
546 #. type: TP
547 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
548 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
549 #, no-wrap
550 msgid "B<ioctl>(2)"
551 msgstr ""
552
553 #. type: Plain text
554 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
555 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
556 msgid "The following timerfd-specific command is supported:"
557 msgstr ""
558
559 #. type: TP
560 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
561 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
562 #, no-wrap
563 msgid "B<TFD_IOC_SET_TICKS> (since Linux 3.17)"
564 msgstr ""
565
566 #. commit 5442e9fbd7c23172a1c9bc736629cd123a9923f0
567 #. type: Plain text
568 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
569 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
570 msgid ""
571 "Adjust the number of timer expirations that have occurred. The argument is "
572 "a pointer to a nonzero 8-byte integer (I<uint64_t>*) containing the new "
573 "number of expirations. Once the number is set, any waiter on the timer is "
574 "woken up. The only purpose of this command is to restore the expirations "
575 "for the purpose of checkpoint/restore. This operation is available only if "
576 "the kernel was configured with the B<CONFIG_CHECKPOINT_RESTORE> option."
577 msgstr ""
578
579 #. type: TP
580 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
581 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
582 #, no-wrap
583 msgid "B<close>(2)"
584 msgstr ""
585
586 #. type: Plain text
587 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
588 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
589 msgid ""
590 "When the file descriptor is no longer required it should be closed. When "
591 "all file descriptors associated with the same timer object have been closed, "
592 "the timer is disarmed and its resources are freed by the kernel."
593 msgstr ""
594
595 #. type: SS
596 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
597 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
598 #, no-wrap
599 msgid "fork(2) semantics"
600 msgstr ""
601
602 #. type: Plain text
603 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
604 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
605 msgid ""
606 "After a B<fork>(2), the child inherits a copy of the file descriptor created "
607 "by B<timerfd_create>(). The file descriptor refers to the same underlying "
608 "timer object as the corresponding file descriptor in the parent, and "
609 "B<read>(2)s in the child will return information about expirations of the "
610 "timer."
611 msgstr ""
612
613 #. type: SS
614 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
615 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
616 #, no-wrap
617 msgid "execve(2) semantics"
618 msgstr ""
619
620 #. type: Plain text
621 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
622 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
623 msgid ""
624 "A file descriptor created by B<timerfd_create>() is preserved across "
625 "B<execve>(2), and continues to generate timer expirations if the timer was "
626 "armed."
627 msgstr ""
628
629 #. type: SH
630 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
631 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
632 #, no-wrap
633 msgid "RETURN VALUE"
634 msgstr ""
635
636 #. type: Plain text
637 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
638 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
639 msgid ""
640 "On success, B<timerfd_create>() returns a new file descriptor. On error, "
641 "-1 is returned and I<errno> is set to indicate the error."
642 msgstr ""
643
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 "B<timerfd_settime>() and B<timerfd_gettime>() return 0 on success; on "
649 "error they return -1, and set I<errno> to indicate the error."
650 msgstr ""
651
652 #. type: SH
653 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
654 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
655 #, no-wrap
656 msgid "ERRORS"
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 "B<timerfd_create>() can fail with the following errors:"
663 msgstr ""
664
665 #. type: TP
666 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
667 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
668 #, no-wrap
669 msgid "B<EINVAL>"
670 msgstr ""
671
672 #. type: Plain text
673 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
674 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
675 msgid "The I<clockid> is not valid."
676 msgstr ""
677
678 #. type: Plain text
679 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
680 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
681 msgid ""
682 "I<flags> is invalid; or, in Linux 2.6.26 or earlier, I<flags> is nonzero."
683 msgstr ""
684
685 #. type: TP
686 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
687 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
688 #, no-wrap
689 msgid "B<EMFILE>"
690 msgstr ""
691
692 #. type: Plain text
693 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
694 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
695 msgid ""
696 "The per-process limit on the number of open file descriptors has been "
697 "reached."
698 msgstr ""
699
700 #. type: TP
701 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
702 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
703 #, no-wrap
704 msgid "B<ENFILE>"
705 msgstr ""
706
707 #. type: Plain text
708 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
709 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
710 msgid ""
711 "The system-wide limit on the total number of open files has been reached."
712 msgstr ""
713
714 #. type: TP
715 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
716 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
717 #, no-wrap
718 msgid "B<ENODEV>"
719 msgstr ""
720
721 #. type: Plain text
722 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
723 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
724 msgid "Could not mount (internal) anonymous inode device."
725 msgstr ""
726
727 #. type: TP
728 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
729 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
730 #, no-wrap
731 msgid "B<ENOMEM>"
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 "There was insufficient kernel memory to create the timer."
738 msgstr ""
739
740 #. type: TP
741 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
742 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
743 #, no-wrap
744 msgid "B<EPERM>"
745 msgstr ""
746
747 #. type: Plain text
748 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
749 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
750 msgid ""
751 "I<clockid> was B<CLOCK_REALTIME_ALARM> or B<CLOCK_BOOTTIME_ALARM> but the "
752 "caller did not have the B<CAP_WAKE_ALARM> capability."
753 msgstr ""
754
755 #. type: Plain text
756 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
757 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
758 msgid ""
759 "B<timerfd_settime>() and B<timerfd_gettime>() can fail with the following "
760 "errors:"
761 msgstr ""
762
763 #. type: TP
764 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
765 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
766 #, no-wrap
767 msgid "B<EBADF>"
768 msgstr ""
769
770 #. type: Plain text
771 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
772 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
773 msgid "I<fd> is not a valid file descriptor."
774 msgstr ""
775
776 #. type: TP
777 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
778 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
779 #, no-wrap
780 msgid "B<EFAULT>"
781 msgstr ""
782
783 #. type: Plain text
784 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
785 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
786 msgid "I<new_value>, I<old_value>, or I<curr_value> is not a valid pointer."
787 msgstr ""
788
789 #. type: Plain text
790 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
791 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
792 msgid "I<fd> is not a valid timerfd file descriptor."
793 msgstr ""
794
795 #. type: Plain text
796 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
797 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
798 msgid "B<timerfd_settime>() can also fail with the following errors:"
799 msgstr ""
800
801 #. type: TP
802 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
803 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
804 #, no-wrap
805 msgid "B<ECANCELED>"
806 msgstr ""
807
808 #. type: Plain text
809 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
810 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
811 msgid "See NOTES."
812 msgstr ""
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 "I<new_value> is not properly initialized (one of the I<tv_nsec> falls "
819 "outside the range zero to 999,999,999)."
820 msgstr ""
821
822 #. This case only checked since Linux 2.6.29, and Linux 2.2.2[78].some-stable-version.
823 #. In older kernel versions, no check was made for invalid flags.
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 "I<flags> is invalid."
828 msgstr ""
829
830 #. type: SH
831 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
832 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
833 #, no-wrap
834 msgid "STANDARDS"
835 msgstr ""
836
837 #. type: Plain text
838 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
839 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
840 msgid "Linux."
841 msgstr ""
842
843 #. type: SH
844 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
845 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
846 #, no-wrap
847 msgid "HISTORY"
848 msgstr ""
849
850 #. type: Plain text
851 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
852 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
853 msgid "Linux 2.6.25, glibc 2.8."
854 msgstr ""
855
856 #. type: SH
857 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
858 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
859 #, no-wrap
860 msgid "NOTES"
861 msgstr ""
862
863 #. type: Plain text
864 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
865 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
866 msgid ""
867 "Suppose the following scenario for B<CLOCK_REALTIME> or "
868 "B<CLOCK_REALTIME_ALARM> timer that was created with B<timerfd_create>():"
869 msgstr ""
870
871 #. type: IP
872 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
873 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
874 #, no-wrap
875 msgid "(1)"
876 msgstr ""
877
878 #. type: Plain text
879 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
880 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
881 msgid ""
882 "The timer has been started (B<timerfd_settime>()) with the "
883 "B<TFD_TIMER_ABSTIME> and B<TFD_TIMER_CANCEL_ON_SET> flags;"
884 msgstr ""
885
886 #. type: IP
887 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
888 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
889 #, no-wrap
890 msgid "(2)"
891 msgstr ""
892
893 #. type: Plain text
894 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
895 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
896 msgid ""
897 "A discontinuous change (e.g., B<settimeofday>(2)) is subsequently made to "
898 "the B<CLOCK_REALTIME> clock; and"
899 msgstr ""
900
901 #. type: IP
902 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
903 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
904 #, no-wrap
905 msgid "(3)"
906 msgstr ""
907
908 #. type: Plain text
909 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
910 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
911 msgid ""
912 "the caller once more calls B<timerfd_settime>() to rearm the timer (without "
913 "first doing a B<read>(2) on the file descriptor)."
914 msgstr ""
915
916 #. type: Plain text
917 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
918 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
919 msgid "In this case the following occurs:"
920 msgstr ""
921
922 #. type: IP
923 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
924 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
925 #, no-wrap
926 msgid "\\[bu]"
927 msgstr ""
928
929 #. type: Plain text
930 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
931 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
932 msgid ""
933 "The B<timerfd_settime>() returns -1 with I<errno> set to B<ECANCELED>. "
934 "(This enables the caller to know that the previous timer was affected by a "
935 "discontinuous change to the clock.)"
936 msgstr ""
937
938 #. type: Plain text
939 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
940 #: opensuse-tumbleweed
941 msgid ""
942 "The timer I<is successfully rearmed> with the settings provided in the "
943 "second B<timerfd_settime>() call. (This was probably an implementation "
944 "accident, but won't be fixed now, in case there are applications that depend "
945 "on this behavior.)"
946 msgstr ""
947
948 #. type: SH
949 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
950 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
951 #, no-wrap
952 msgid "BUGS"
953 msgstr ""
954
955 #. 2.6.29
956 #. type: Plain text
957 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
958 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
959 msgid ""
960 "Currently, B<timerfd_create>() supports fewer types of clock IDs than "
961 "B<timer_create>(2)."
962 msgstr ""
963
964 #. type: SH
965 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
966 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
967 #, no-wrap
968 msgid "EXAMPLES"
969 msgstr ""
970
971 #. type: Plain text
972 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
973 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
974 msgid ""
975 "The following program creates a timer and then monitors its progress. The "
976 "program accepts up to three command-line arguments. The first argument "
977 "specifies the number of seconds for the initial expiration of the timer. "
978 "The second argument specifies the interval for the timer, in seconds. The "
979 "third argument specifies the number of times the program should allow the "
980 "timer to expire before terminating. The second and third command-line "
981 "arguments are optional."
982 msgstr ""
983
984 #. type: Plain text
985 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
986 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
987 msgid "The following shell session demonstrates the use of the program:"
988 msgstr ""
989
990 #. type: Plain text
991 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
992 #: opensuse-tumbleweed
993 #, no-wrap
994 msgid ""
995 "$B< a.out 3 1 100>\n"
996 "0.000:\ttimer started\n"
997 "3.000:\tread: 1; total=1\n"
998 "4.000:\tread: 1; total=2\n"
999 "B<\\[ha]Z > # type control-Z to suspend the program\n"
1000 "[1]+ Stopped ./timerfd3_demo 3 1 100\n"
1001 "$ B<fg> # Resume execution after a few seconds\n"
1002 "a.out 3 1 100\n"
1003 "9.660:\tread: 5; total=7\n"
1004 "10.000:\tread: 1; total=8\n"
1005 "11.000:\tread: 1; total=9\n"
1006 "B<\\[ha]C > # type control-C to suspend the program\n"
1007 msgstr ""
1008
1009 #. type: SS
1010 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1011 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1012 #, no-wrap
1013 msgid "Program source"
1014 msgstr ""
1015
1016 #
1017 #
1018 #
1019 #
1020 #
1021 #
1022 #
1023 #. The commented out code here is what we currently need until
1024 #. the required stuff is in glibc
1025 #. /* Link with \-lrt */
1026 #. #define _GNU_SOURCE
1027 #. #include <sys/syscall.h>
1028 #. #include <unistd.h>
1029 #. #include <time.h>
1030 #. #if defined(__i386__)
1031 #. #define __NR_timerfd_create 322
1032 #. #define __NR_timerfd_settime 325
1033 #. #define __NR_timerfd_gettime 326
1034 #. #endif
1035 #. static int
1036 #. timerfd_create(int clockid, int flags)
1037 #. {
1038 #. return syscall(__NR_timerfd_create, clockid, flags);
1039 #. }
1040 #. static int
1041 #. timerfd_settime(int fd, int flags, struct itimerspec *new_value,
1042 #. struct itimerspec *curr_value)
1043 #. {
1044 #. return syscall(__NR_timerfd_settime, fd, flags, new_value,
1045 #. curr_value);
1046 #. }
1047 #. static int
1048 #. timerfd_gettime(int fd, struct itimerspec *curr_value)
1049 #. {
1050 #. return syscall(__NR_timerfd_gettime, fd, curr_value);
1051 #. }
1052 #. #define TFD_TIMER_ABSTIME (1 << 0)
1053 #. ////////////////////////////////////////////////////////////
1054 #. type: Plain text
1055 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
1056 #, no-wrap
1057 msgid ""
1058 "#include E<lt>err.hE<gt>\n"
1059 "#include E<lt>inttypes.hE<gt>\n"
1060 "#include E<lt>stdio.hE<gt>\n"
1061 "#include E<lt>stdlib.hE<gt>\n"
1062 "#include E<lt>sys/timerfd.hE<gt>\n"
1063 "#include E<lt>sys/types.hE<gt>\n"
1064 "#include E<lt>time.hE<gt>\n"
1065 "#include E<lt>unistd.hE<gt>\n"
1066 "\\&\n"
1067 "static void\n"
1068 "print_elapsed_time(void)\n"
1069 "{\n"
1070 " int secs, nsecs;\n"
1071 " static int first_call = 1;\n"
1072 " struct timespec curr;\n"
1073 " static struct timespec start;\n"
1074 "\\&\n"
1075 " if (first_call) {\n"
1076 " first_call = 0;\n"
1077 " if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)\n"
1078 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1079 " }\n"
1080 "\\&\n"
1081 " if (clock_gettime(CLOCK_MONOTONIC, &curr) == -1)\n"
1082 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1083 "\\&\n"
1084 " secs = curr.tv_sec - start.tv_sec;\n"
1085 " nsecs = curr.tv_nsec - start.tv_nsec;\n"
1086 " if (nsecs E<lt> 0) {\n"
1087 " secs--;\n"
1088 " nsecs += 1000000000;\n"
1089 " }\n"
1090 " printf(\"%d.%03d:\\[rs]t\", secs, (nsecs + 500000) / 1000000);\n"
1091 "}\n"
1092 "\\&\n"
1093 "int\n"
1094 "main(int argc, char *argv[])\n"
1095 "{\n"
1096 " int fd;\n"
1097 " ssize_t s;\n"
1098 " uint64_t expir, tot_expir, max_expir;\n"
1099 " struct timespec now;\n"
1100 " struct itimerspec new_value;\n"
1101 "\\&\n"
1102 " if (argc != 2 && argc != 4) {\n"
1103 " fprintf(stderr, \"%s init-secs [interval-secs max-num-expir]\\[rs]n\",\n"
1104 " argv[0]);\n"
1105 " exit(EXIT_FAILURE);\n"
1106 " }\n"
1107 "\\&\n"
1108 " if (clock_gettime(CLOCK_REALTIME, &now) == -1)\n"
1109 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1110 "\\&\n"
1111 " /* Create a CLOCK_REALTIME absolute timer with initial\n"
1112 " expiration and interval as specified in command line. */\n"
1113 "\\&\n"
1114 " new_value.it_value.tv_sec = now.tv_sec + atoi(argv[1]);\n"
1115 " new_value.it_value.tv_nsec = now.tv_nsec;\n"
1116 " if (argc == 2) {\n"
1117 " new_value.it_interval.tv_sec = 0;\n"
1118 " max_expir = 1;\n"
1119 " } else {\n"
1120 " new_value.it_interval.tv_sec = atoi(argv[2]);\n"
1121 " max_expir = atoi(argv[3]);\n"
1122 " }\n"
1123 " new_value.it_interval.tv_nsec = 0;\n"
1124 "\\&\n"
1125 " fd = timerfd_create(CLOCK_REALTIME, 0);\n"
1126 " if (fd == -1)\n"
1127 " err(EXIT_FAILURE, \"timerfd_create\");\n"
1128 "\\&\n"
1129 " if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &new_value, NULL) == -1)\n"
1130 " err(EXIT_FAILURE, \"timerfd_settime\");\n"
1131 "\\&\n"
1132 " print_elapsed_time();\n"
1133 " printf(\"timer started\\[rs]n\");\n"
1134 "\\&\n"
1135 " for (tot_expir = 0; tot_expir E<lt> max_expir;) {\n"
1136 " s = read(fd, &expir, sizeof(uint64_t));\n"
1137 " if (s != sizeof(uint64_t))\n"
1138 " err(EXIT_FAILURE, \"read\");\n"
1139 "\\&\n"
1140 " tot_expir += expir;\n"
1141 " print_elapsed_time();\n"
1142 " printf(\"read: %w64u; total=%w64u\\[rs]n\", expir, tot_expir);\n"
1143 " }\n"
1144 "\\&\n"
1145 " exit(EXIT_SUCCESS);\n"
1146 "}\n"
1147 msgstr ""
1148
1149 #. SRC END
1150 #. type: SH
1151 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1152 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1153 #, no-wrap
1154 msgid "SEE ALSO"
1155 msgstr ""
1156
1157 #. type: Plain text
1158 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1159 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1160 msgid ""
1161 "B<eventfd>(2), B<poll>(2), B<read>(2), B<select>(2), B<setitimer>(2), "
1162 "B<signalfd>(2), B<timer_create>(2), B<timer_gettime>(2), "
1163 "B<timer_settime>(2), B<timespec>(3), B<epoll>(7), B<time>(7)"
1164 msgstr ""
1165
1166 #. type: TH
1167 #: debian-trixie
1168 #, no-wrap
1169 msgid "2024-06-15"
1170 msgstr ""
1171
1172 #. type: TH
1173 #: debian-trixie
1174 #, no-wrap
1175 msgid "Linux man-pages 6.9.1"
1176 msgstr ""
1177
1178 #. type: Plain text
1179 #: debian-trixie
1180 msgid "Standard C library (I<libc>, I<-lc>)"
1181 msgstr ""
1182
1183 #. type: Plain text
1184 #: debian-trixie fedora-44 fedora-rawhide
1185 msgid ""
1186 "The timer I<is successfully rearmed> with the settings provided in the "
1187 "second B<timerfd_settime>() call. (This was probably an implementation "
1188 "accident, but won't be fixed now, in case there are applications that depend "
1189 "on this behaviour.)"
1190 msgstr ""
1191
1192 #. type: Plain text
1193 #: debian-trixie fedora-44 fedora-rawhide
1194 #, no-wrap
1195 msgid ""
1196 "$B< a.out 3 1 100>\n"
1197 "0.000: timer started\n"
1198 "3.000: read: 1; total=1\n"
1199 "4.000: read: 1; total=2\n"
1200 "B<\\[ha]Z > # type control-Z to suspend the program\n"
1201 "[1]+ Stopped ./timerfd3_demo 3 1 100\n"
1202 "$ B<fg> # Resume execution after a few seconds\n"
1203 "a.out 3 1 100\n"
1204 "9.660: read: 5; total=7\n"
1205 "10.000: read: 1; total=8\n"
1206 "11.000: read: 1; total=9\n"
1207 "B<\\[ha]C > # type control-C to suspend the program\n"
1208 msgstr ""
1209
1210 #
1211 #
1212 #
1213 #
1214 #
1215 #
1216 #
1217 #. The commented out code here is what we currently need until
1218 #. the required stuff is in glibc
1219 #. /* Link with \-lrt */
1220 #. #define _GNU_SOURCE
1221 #. #include <sys/syscall.h>
1222 #. #include <unistd.h>
1223 #. #include <time.h>
1224 #. #if defined(__i386__)
1225 #. #define __NR_timerfd_create 322
1226 #. #define __NR_timerfd_settime 325
1227 #. #define __NR_timerfd_gettime 326
1228 #. #endif
1229 #. static int
1230 #. timerfd_create(int clockid, int flags)
1231 #. {
1232 #. return syscall(__NR_timerfd_create, clockid, flags);
1233 #. }
1234 #. static int
1235 #. timerfd_settime(int fd, int flags, struct itimerspec *new_value,
1236 #. struct itimerspec *curr_value)
1237 #. {
1238 #. return syscall(__NR_timerfd_settime, fd, flags, new_value,
1239 #. curr_value);
1240 #. }
1241 #. static int
1242 #. timerfd_gettime(int fd, struct itimerspec *curr_value)
1243 #. {
1244 #. return syscall(__NR_timerfd_gettime, fd, curr_value);
1245 #. }
1246 #. #define TFD_TIMER_ABSTIME (1 << 0)
1247 #. ////////////////////////////////////////////////////////////
1248 #. type: Plain text
1249 #: debian-trixie fedora-44 fedora-rawhide
1250 #, no-wrap
1251 msgid ""
1252 "#include E<lt>err.hE<gt>\n"
1253 "#include E<lt>inttypes.hE<gt>\n"
1254 "#include E<lt>stdio.hE<gt>\n"
1255 "#include E<lt>stdlib.hE<gt>\n"
1256 "#include E<lt>sys/timerfd.hE<gt>\n"
1257 "#include E<lt>sys/types.hE<gt>\n"
1258 "#include E<lt>time.hE<gt>\n"
1259 "#include E<lt>unistd.hE<gt>\n"
1260 "\\&\n"
1261 "static void\n"
1262 "print_elapsed_time(void)\n"
1263 "{\n"
1264 " int secs, nsecs;\n"
1265 " static int first_call = 1;\n"
1266 " struct timespec curr;\n"
1267 " static struct timespec start;\n"
1268 "\\&\n"
1269 " if (first_call) {\n"
1270 " first_call = 0;\n"
1271 " if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)\n"
1272 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1273 " }\n"
1274 "\\&\n"
1275 " if (clock_gettime(CLOCK_MONOTONIC, &curr) == -1)\n"
1276 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1277 "\\&\n"
1278 " secs = curr.tv_sec - start.tv_sec;\n"
1279 " nsecs = curr.tv_nsec - start.tv_nsec;\n"
1280 " if (nsecs E<lt> 0) {\n"
1281 " secs--;\n"
1282 " nsecs += 1000000000;\n"
1283 " }\n"
1284 " printf(\"%d.%03d: \", secs, (nsecs + 500000) / 1000000);\n"
1285 "}\n"
1286 "\\&\n"
1287 "int\n"
1288 "main(int argc, char *argv[])\n"
1289 "{\n"
1290 " int fd;\n"
1291 " ssize_t s;\n"
1292 " uint64_t exp, tot_exp, max_exp;\n"
1293 " struct timespec now;\n"
1294 " struct itimerspec new_value;\n"
1295 "\\&\n"
1296 " if (argc != 2 && argc != 4) {\n"
1297 " fprintf(stderr, \"%s init-secs [interval-secs max-exp]\\[rs]n\",\n"
1298 " argv[0]);\n"
1299 " exit(EXIT_FAILURE);\n"
1300 " }\n"
1301 "\\&\n"
1302 " if (clock_gettime(CLOCK_REALTIME, &now) == -1)\n"
1303 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1304 "\\&\n"
1305 " /* Create a CLOCK_REALTIME absolute timer with initial\n"
1306 " expiration and interval as specified in command line. */\n"
1307 "\\&\n"
1308 " new_value.it_value.tv_sec = now.tv_sec + atoi(argv[1]);\n"
1309 " new_value.it_value.tv_nsec = now.tv_nsec;\n"
1310 " if (argc == 2) {\n"
1311 " new_value.it_interval.tv_sec = 0;\n"
1312 " max_exp = 1;\n"
1313 " } else {\n"
1314 " new_value.it_interval.tv_sec = atoi(argv[2]);\n"
1315 " max_exp = atoi(argv[3]);\n"
1316 " }\n"
1317 " new_value.it_interval.tv_nsec = 0;\n"
1318 "\\&\n"
1319 " fd = timerfd_create(CLOCK_REALTIME, 0);\n"
1320 " if (fd == -1)\n"
1321 " err(EXIT_FAILURE, \"timerfd_create\");\n"
1322 "\\&\n"
1323 " if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &new_value, NULL) == -1)\n"
1324 " err(EXIT_FAILURE, \"timerfd_settime\");\n"
1325 "\\&\n"
1326 " print_elapsed_time();\n"
1327 " printf(\"timer started\\[rs]n\");\n"
1328 "\\&\n"
1329 " for (tot_exp = 0; tot_exp E<lt> max_exp;) {\n"
1330 " s = read(fd, &exp, sizeof(uint64_t));\n"
1331 " if (s != sizeof(uint64_t))\n"
1332 " err(EXIT_FAILURE, \"read\");\n"
1333 "\\&\n"
1334 " tot_exp += exp;\n"
1335 " print_elapsed_time();\n"
1336 " printf(\"read: %\" PRIu64 \"; total=%\" PRIu64 \"\\[rs]n\", exp, tot_exp);\n"
1337 " }\n"
1338 "\\&\n"
1339 " exit(EXIT_SUCCESS);\n"
1340 "}\n"
1341 msgstr ""
1342
1343 #. type: TH
1344 #: fedora-44 fedora-rawhide
1345 #, no-wrap
1346 msgid "2024-07-23"
1347 msgstr ""
1348
1349 #. type: TH
1350 #: fedora-44 fedora-rawhide
1351 #, no-wrap
1352 msgid "Linux man-pages 6.13"
1353 msgstr ""
1354
1355 #. type: TH
1356 #: mageia-cauldron
1357 #, no-wrap
1358 msgid "2026-02-08"
1359 msgstr ""
1360
1361 #. type: TH
1362 #: mageia-cauldron
1363 #, no-wrap
1364 msgid "Linux man-pages 6.17"
1365 msgstr ""
1366
1367 #
1368 #
1369 #
1370 #
1371 #
1372 #
1373 #
1374 #. The commented out code here is what we currently need until
1375 #. the required stuff is in glibc
1376 #. /* Link with \-lrt */
1377 #. #define _GNU_SOURCE
1378 #. #include <sys/syscall.h>
1379 #. #include <unistd.h>
1380 #. #include <time.h>
1381 #. #if defined(__i386__)
1382 #. #define __NR_timerfd_create 322
1383 #. #define __NR_timerfd_settime 325
1384 #. #define __NR_timerfd_gettime 326
1385 #. #endif
1386 #. static int
1387 #. timerfd_create(int clockid, int flags)
1388 #. {
1389 #. return syscall(__NR_timerfd_create, clockid, flags);
1390 #. }
1391 #. static int
1392 #. timerfd_settime(int fd, int flags, struct itimerspec *new_value,
1393 #. struct itimerspec *curr_value)
1394 #. {
1395 #. return syscall(__NR_timerfd_settime, fd, flags, new_value,
1396 #. curr_value);
1397 #. }
1398 #. static int
1399 #. timerfd_gettime(int fd, struct itimerspec *curr_value)
1400 #. {
1401 #. return syscall(__NR_timerfd_gettime, fd, curr_value);
1402 #. }
1403 #. #define TFD_TIMER_ABSTIME (1 << 0)
1404 #. ////////////////////////////////////////////////////////////
1405 #. type: Plain text
1406 #: mageia-cauldron
1407 #, no-wrap
1408 msgid ""
1409 "#include E<lt>err.hE<gt>\n"
1410 "#include E<lt>inttypes.hE<gt>\n"
1411 "#include E<lt>stdio.hE<gt>\n"
1412 "#include E<lt>stdlib.hE<gt>\n"
1413 "#include E<lt>sys/timerfd.hE<gt>\n"
1414 "#include E<lt>sys/types.hE<gt>\n"
1415 "#include E<lt>time.hE<gt>\n"
1416 "#include E<lt>unistd.hE<gt>\n"
1417 "\\&\n"
1418 "static void\n"
1419 "print_elapsed_time(void)\n"
1420 "{\n"
1421 " int secs, nsecs;\n"
1422 " static int first_call = 1;\n"
1423 " struct timespec curr;\n"
1424 " static struct timespec start;\n"
1425 "\\&\n"
1426 " if (first_call) {\n"
1427 " first_call = 0;\n"
1428 " if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)\n"
1429 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1430 " }\n"
1431 "\\&\n"
1432 " if (clock_gettime(CLOCK_MONOTONIC, &curr) == -1)\n"
1433 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1434 "\\&\n"
1435 " secs = curr.tv_sec - start.tv_sec;\n"
1436 " nsecs = curr.tv_nsec - start.tv_nsec;\n"
1437 " if (nsecs E<lt> 0) {\n"
1438 " secs--;\n"
1439 " nsecs += 1000000000;\n"
1440 " }\n"
1441 " printf(\"%d.%03d:\\[rs]t\", secs, (nsecs + 500000) / 1000000);\n"
1442 "}\n"
1443 "\\&\n"
1444 "int\n"
1445 "main(int argc, char *argv[])\n"
1446 "{\n"
1447 " int fd;\n"
1448 " ssize_t s;\n"
1449 " uint64_t expir, tot_expir, max_expir;\n"
1450 " struct timespec now;\n"
1451 " struct itimerspec new_value;\n"
1452 "\\&\n"
1453 " if (argc != 2 && argc != 4) {\n"
1454 " fprintf(stderr, \"%s init-secs [interval-secs max-num-expir]\\[rs]n\",\n"
1455 " argv[0]);\n"
1456 " exit(EXIT_FAILURE);\n"
1457 " }\n"
1458 "\\&\n"
1459 " if (clock_gettime(CLOCK_REALTIME, &now) == -1)\n"
1460 " err(EXIT_FAILURE, \"clock_gettime\");\n"
1461 "\\&\n"
1462 " /* Create a CLOCK_REALTIME absolute timer with initial\n"
1463 " expiration and interval as specified in command line. */\n"
1464 "\\&\n"
1465 " new_value.it_value.tv_sec = now.tv_sec + atoi(argv[1]);\n"
1466 " new_value.it_value.tv_nsec = now.tv_nsec;\n"
1467 " if (argc == 2) {\n"
1468 " new_value.it_interval.tv_sec = 0;\n"
1469 " max_expir = 1;\n"
1470 " } else {\n"
1471 " new_value.it_interval.tv_sec = atoi(argv[2]);\n"
1472 " max_expir = atoi(argv[3]);\n"
1473 " }\n"
1474 " new_value.it_interval.tv_nsec = 0;\n"
1475 "\\&\n"
1476 " fd = timerfd_create(CLOCK_REALTIME, 0);\n"
1477 " if (fd == -1)\n"
1478 " err(EXIT_FAILURE, \"timerfd_create\");\n"
1479 "\\&\n"
1480 " if (timerfd_settime(fd, TFD_TIMER_ABSTIME, &new_value, NULL) == -1)\n"
1481 " err(EXIT_FAILURE, \"timerfd_settime\");\n"
1482 "\\&\n"
1483 " print_elapsed_time();\n"
1484 " printf(\"timer started\\[rs]n\");\n"
1485 "\\&\n"
1486 " for (tot_expir = 0; tot_expir E<lt> max_expir;) {\n"
1487 " s = read(fd, &expir, sizeof(uint64_t));\n"
1488 " if (s != sizeof(uint64_t))\n"
1489 " err(EXIT_FAILURE, \"read\");\n"
1490 "\\&\n"
1491 " tot_expir += expir;\n"
1492 " print_elapsed_time();\n"
1493 " printf(\"read: %\" PRIu64 \"; total=%\" PRIu64 \"\\[rs]n\",\n"
1494 " expir, tot_expir);\n"
1495 " }\n"
1496 "\\&\n"
1497 " exit(EXIT_SUCCESS);\n"
1498 "}\n"
1499 msgstr ""
1500
1501 #. type: TH
1502 #: opensuse-leap-16-1 opensuse-tumbleweed
1503 #, no-wrap
1504 msgid "Linux man-pages (unreleased)"
1505 msgstr ""