Debian Codegraph @

po/ru/man3/sem_wait.3.po

raw
1 # Russian translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 # Alexander Golubev <[email protected]>, 2018.
5 # Azamat Hackimov <[email protected]>, 2011, 2014-2016.
6 # Hotellook, 2014.
7 # Nikita <[email protected]>, 2014.
8 # Spiros Georgaras <[email protected]>, 2016.
9 # Vladislav <[email protected]>, 2015.
10 # Yuri Kozlov <[email protected]>, 2011-2019.
11 # Иван Павлов <[email protected]>, 2017.
12 msgid ""
13 msgstr ""
14 "Project-Id-Version: manpages-l10n\n"
15 "POT-Creation-Date: 2026-06-05 06:42+0200\n"
16 "PO-Revision-Date: 2024-12-21 19:50+0300\n"
17 "Last-Translator: Yuri Kozlov <[email protected]>\n"
18 "Language-Team: Russian <[email protected]>\n"
19 "Language: ru\n"
20 "MIME-Version: 1.0\n"
21 "Content-Type: text/plain; charset=UTF-8\n"
22 "Content-Transfer-Encoding: 8bit\n"
23 "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
24 "n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || "
25 "(n%100>=11 && n%100<=14)? 2 : 3);\n"
26 "X-Generator: Lokalize 2.0\n"
27
28 #. type: TH
29 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
30 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
31 #, no-wrap
32 msgid "sem_wait"
33 msgstr ""
34
35 #. type: TH
36 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
37 #: opensuse-tumbleweed
38 #, no-wrap
39 msgid "2026-02-08"
40 msgstr "8 февраля 2026 г."
41
42 #. type: TH
43 #: archlinux debian-unstable
44 #, fuzzy, no-wrap
45 #| msgid "Linux man-pages 6.17"
46 msgid "Linux man-pages 6.18"
47 msgstr "Справочные страницы Linux 6.17"
48
49 #. type: SH
50 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
51 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
52 #, no-wrap
53 msgid "NAME"
54 msgstr "НАИМЕНОВАНИЕ"
55
56 #. type: Plain text
57 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
58 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
59 msgid "sem_wait, sem_timedwait, sem_trywait - lock a semaphore"
60 msgstr "sem_wait, sem_timedwait, sem_trywait - блокирует семафор"
61
62 #. type: SH
63 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
64 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
65 #, no-wrap
66 msgid "LIBRARY"
67 msgstr "БИБЛИОТЕКА"
68
69 #. type: Plain text
70 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
71 #: opensuse-leap-16-1 opensuse-tumbleweed
72 msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)"
73 msgstr "Библиотека потоков POSIX (I<libpthread>,\\ I<-lpthread>)"
74
75 #. type: SH
76 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
77 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
78 #, no-wrap
79 msgid "SYNOPSIS"
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 #, no-wrap
86 msgid "B<#include E<lt>semaphore.hE<gt>>\n"
87 msgstr "B<#include E<lt>semaphore.hE<gt>>\n"
88
89 #. type: Plain text
90 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
91 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
92 #, fuzzy, no-wrap
93 #| msgid ""
94 #| "B<int semtimedop(int >I<semid>B<, struct sembuf *>I<sops>B<, size_t >I<nsops>B<,>\n"
95 #| "B< const struct timespec *>I<timeout>B<);>\n"
96 msgid ""
97 "B<int sem_wait(sem_t *>I<sem>B<);>\n"
98 "B<int sem_trywait(sem_t *>I<sem>B<);>\n"
99 "B<int sem_timedwait(sem_t *restrict >I<sem>B<,>\n"
100 "B< const struct timespec *restrict >I<abs_timeout>B<);>\n"
101 msgstr ""
102 "B<int semtimedop(int >I<semid>B<, struct sembuf *>I<sops>B<, size_t >I<nsops>B<,>\n"
103 "B< const struct timespec *>I<timeout>B<);>\n"
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 "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
110 msgstr ""
111 "Требования макроса тестирования свойств для glibc (см. "
112 "B<feature_test_macros>(7)):"
113
114 #. type: Plain text
115 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
116 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
117 #, fuzzy
118 #| msgid "B<sigtimedwait>(2)"
119 msgid "B<sem_timedwait>():"
120 msgstr "B<sigtimedwait>(2)"
121
122 #. type: Plain text
123 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
124 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
125 #, no-wrap
126 msgid " _POSIX_C_SOURCE E<gt>= 200112L\n"
127 msgstr " _POSIX_C_SOURCE E<gt>= 200112L\n"
128
129 #. type: SH
130 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
131 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
132 #, no-wrap
133 msgid "DESCRIPTION"
134 msgstr "ОПИСАНИЕ"
135
136 #. type: Plain text
137 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
138 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
139 msgid ""
140 "B<sem_wait>() decrements (locks) the semaphore pointed to by I<sem>. If "
141 "the semaphore's value is greater than zero, then the decrement proceeds, and "
142 "the function returns, immediately. If the semaphore currently has the value "
143 "zero, then the call blocks until either it becomes possible to perform the "
144 "decrement (i.e., the semaphore value rises above zero), or a signal handler "
145 "interrupts the call."
146 msgstr ""
147 "Функция B<sem_wait>() уменьшает (блокирует) семафор, на который указывает "
148 "I<sem>. Если значение семафор больше нуля, то выполняется уменьшение и "
149 "функция сразу завершается. Если значение семафора равно нулю, то вызов "
150 "блокируется до тех пор, пока не станет возможным выполнить уменьшение (т. "
151 "е., значение семафора не станет больше нуля), или пока не вызовется "
152 "обработчик сигнала."
153
154 #. type: Plain text
155 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
156 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
157 msgid ""
158 "B<sem_trywait>() is the same as B<sem_wait>(), except that if the decrement "
159 "cannot be immediately performed, then call returns an error (I<errno> set to "
160 "B<EAGAIN>) instead of blocking."
161 msgstr ""
162 "Функция B<sem_trywait>() подобна B<sem_wait>(), за исключением того, что "
163 "если уменьшение нельзя выполнить сразу, то вызов завершается с ошибкой "
164 "(I<errno> становится равным B<EAGAIN>), а не блокируется."
165
166 #. type: Plain text
167 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
168 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
169 #, fuzzy
170 #| msgid ""
171 #| "B<sem_timedwait>() is the same as B<sem_wait>(), except that "
172 #| "I<abs_timeout> specifies a limit on the amount of time that the call "
173 #| "should block if the decrement cannot be immediately performed. The "
174 #| "I<abs_timeout> argument points to a structure that specifies an absolute "
175 #| "timeout in seconds and nanoseconds since the Epoch, 1970-01-01 00:00:00 "
176 #| "+0000 (UTC). This structure is defined as follows:"
177 msgid ""
178 "B<sem_timedwait>() is the same as B<sem_wait>(), except that I<abs_timeout> "
179 "specifies a limit on the amount of time that the call should block if the "
180 "decrement cannot be immediately performed. The I<abs_timeout> argument "
181 "points to a B<timespec>(3) structure that specifies an absolute timeout in "
182 "seconds and nanoseconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)."
183 msgstr ""
184 "Функция B<sem_timedwait>() подобна B<sem_wait>(), за исключением того, что в "
185 "I<abs_timeout> задаётся ограничение по количеству времени, на которое вызов "
186 "должен заблокироваться, если уменьшение невозможно выполнить сразу. Аргумент "
187 "I<abs_timeout> указывает на структуру, в которой задаётся абсолютное время "
188 "ожидания в секундах и наносекундах, начиная с эпохи, 1970-01-01 00:00:00 "
189 "+0000 (UTC). Эта структура определена следующим образом:"
190
191 #. type: Plain text
192 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
193 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
194 msgid ""
195 "If the timeout has already expired by the time of the call, and the "
196 "semaphore could not be locked immediately, then B<sem_timedwait>() fails "
197 "with a timeout error (I<errno> set to B<ETIMEDOUT>)."
198 msgstr ""
199 "Если на момент вызова время ожидания уже истекло и семафор нельзя "
200 "заблокировать сразу, то B<sem_timedwait>() завершается с ошибкой просрочки "
201 "(I<errno> становится равным B<ETIMEDOUT>)."
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 "If the operation can be performed immediately, then B<sem_timedwait>() "
208 "never fails with a timeout error, regardless of the value of "
209 "I<abs_timeout>. Furthermore, the validity of I<abs_timeout> is not checked "
210 "in this case."
211 msgstr ""
212 "Если операцию можно выполнить сразу, то B<sem_timedwait>() никогда не "
213 "завершится с ошибкой просрочки, независимо от значения I<abs_timeout>. Кроме "
214 "того, в этом случае не проверяется корректность I<abs_timeout>."
215
216 #. type: SH
217 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
218 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
219 #, no-wrap
220 msgid "RETURN VALUE"
221 msgstr "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ"
222
223 #. type: Plain text
224 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
225 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
226 msgid ""
227 "All of these functions return 0 on success; on error, the value of the "
228 "semaphore is left unchanged, -1 is returned, and I<errno> is set to indicate "
229 "the error."
230 msgstr ""
231 "При успешном выполнении все функции возвращают 0; при ошибке значение "
232 "семафора не изменяется, возвращается -1, а в I<errno> указывается причина "
233 "ошибки."
234
235 #. type: SH
236 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
237 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
238 #, no-wrap
239 msgid "ERRORS"
240 msgstr "ОШИБКИ"
241
242 #. type: TP
243 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
244 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
245 #, no-wrap
246 msgid "B<EAGAIN>"
247 msgstr "B<EAGAIN>"
248
249 #. type: Plain text
250 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
251 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
252 #, fuzzy
253 #| msgid ""
254 #| "The operation could not be performed without blocking (i.e., the "
255 #| "semaphore currently has the value zero)."
256 msgid ""
257 "(B<sem_trywait>()) The operation could not be performed without blocking "
258 "(i.e., the semaphore currently has the value zero)."
259 msgstr ""
260 "Операция не может быть выполнена без блокировки (т. е., значение семафор "
261 "равно нулю)."
262
263 #. type: TP
264 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
265 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
266 #, no-wrap
267 msgid "B<EINTR>"
268 msgstr "B<EINTR>"
269
270 #. type: Plain text
271 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
272 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
273 msgid "The call was interrupted by a signal handler; see B<signal>(7)."
274 msgstr "Вызов был прерван обработчиком сигнала; смотрите B<signal>(7)."
275
276 #. type: TP
277 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
278 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
279 #, no-wrap
280 msgid "B<EINVAL>"
281 msgstr "B<EINVAL>"
282
283 #. type: Plain text
284 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
285 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
286 msgid "I<sem> is not a valid semaphore."
287 msgstr "Значение I<sem> не является корректным для семафора."
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 #, fuzzy
293 #| msgid ""
294 #| "The value of I<abs_timeout.tv_nsecs> is less than 0, or greater than or "
295 #| "equal to 1000 million."
296 msgid ""
297 "(B<sem_timedwait>()) The value of I<abs_timeout.tv_nsecs> is less than 0, "
298 "or greater than or equal to 1000 million."
299 msgstr ""
300 "Значение I<abs_timeout.tv_nsecs> меньше 0, или больше или равно 1000 "
301 "миллионов."
302
303 #. type: TP
304 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
305 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
306 #, no-wrap
307 msgid "B<ETIMEDOUT>"
308 msgstr "B<ETIMEDOUT>"
309
310 #. POSIX.1-2001 also allows EDEADLK -- "A deadlock condition
311 #. was detected", but this does not occur on Linux(?).
312 #. type: Plain text
313 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
314 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
315 #, fuzzy
316 #| msgid "The call timed out before the semaphore could be locked."
317 msgid ""
318 "(B<sem_timedwait>()) The call timed out before the semaphore could be "
319 "locked."
320 msgstr "Истёк период ожидания в вызове раньше возможности блокировки семафора."
321
322 #. type: SH
323 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
324 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
325 #, no-wrap
326 msgid "ATTRIBUTES"
327 msgstr "АТРИБУТЫ"
328
329 #. type: Plain text
330 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
331 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
332 msgid ""
333 "For an explanation of the terms used in this section, see B<attributes>(7)."
334 msgstr "Описание терминов данного раздела смотрите в B<attributes>(7)."
335
336 #. type: tbl table
337 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
338 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
339 #, no-wrap
340 msgid "Interface"
341 msgstr "Интерфейс"
342
343 #. type: tbl table
344 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
345 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
346 #, no-wrap
347 msgid "Attribute"
348 msgstr "Атрибут"
349
350 #. type: tbl table
351 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
352 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
353 #, no-wrap
354 msgid "Value"
355 msgstr "Значение"
356
357 #. type: tbl table
358 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
359 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
360 #, no-wrap
361 msgid ".na\n"
362 msgstr ".na\n"
363
364 #. type: tbl table
365 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
366 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
367 #, no-wrap
368 msgid ".nh\n"
369 msgstr ".nh\n"
370
371 #. type: tbl table
372 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
373 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
374 #, no-wrap
375 msgid ""
376 "B<sem_wait>(),\n"
377 "B<sem_trywait>(),\n"
378 "B<sem_timedwait>()"
379 msgstr ""
380 "B<sem_wait>(),\n"
381 "B<sem_trywait>(),\n"
382 "B<sem_timedwait>()"
383
384 #. type: tbl table
385 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
386 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
387 #, no-wrap
388 msgid "Thread safety"
389 msgstr "Безвредность в нитях"
390
391 #. type: tbl table
392 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
393 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
394 #, no-wrap
395 msgid "MT-Safe"
396 msgstr "MT-Safe"
397
398 #. type: SH
399 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
400 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
401 #, no-wrap
402 msgid "STANDARDS"
403 msgstr "СТАНДАРТЫ"
404
405 #. type: Plain text
406 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
407 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
408 msgid "POSIX.1-2008."
409 msgstr "POSIX.1-2008."
410
411 #. type: SH
412 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
413 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
414 #, no-wrap
415 msgid "HISTORY"
416 msgstr "ИСТОРИЯ"
417
418 #. type: Plain text
419 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
420 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
421 msgid "POSIX.1-2001."
422 msgstr "POSIX.1-2001."
423
424 #. type: SH
425 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
426 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
427 #, no-wrap
428 msgid "EXAMPLES"
429 msgstr "ПРИМЕРЫ"
430
431 #. type: Plain text
432 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
433 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
434 msgid ""
435 "The (somewhat trivial) program shown below operates on an unnamed "
436 "semaphore. The program expects two command-line arguments. The first "
437 "argument specifies a seconds value that is used to set an alarm timer to "
438 "generate a B<SIGALRM> signal. This handler performs a B<sem_post>(3) to "
439 "increment the semaphore that is being waited on in I<main()> using "
440 "B<sem_timedwait>(). The second command-line argument specifies the length "
441 "of the timeout, in seconds, for B<sem_timedwait>(). The following shows "
442 "what happens on two different runs of the program:"
443 msgstr ""
444 "Программа (несколько упрощённая), показанная ниже, работает с безымянным "
445 "семафором. Она ожидает два аргумента командной строки. В первом аргументе "
446 "задаётся значение в секундах, которое используется в будильнике для "
447 "генерации сигнала B<SIGALRM>. Этот обработчик выполняет B<sem_post>(3) для "
448 "увеличения семафора, которого ждёт в I<main()> вызов B<sem_timedwait>(). Во "
449 "втором аргументе задаётся период ожидания в секундах для B<sem_timedwait>(). "
450 "Далее показано что происходит в двух разных запусках программы:"
451
452 #. type: Plain text
453 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
454 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
455 #, no-wrap
456 msgid ""
457 "$B< ./a.out 2 3>\n"
458 "About to call sem_timedwait()\n"
459 "sem_post() from handler\n"
460 "sem_timedwait() succeeded\n"
461 "$B< ./a.out 2 1>\n"
462 "About to call sem_timedwait()\n"
463 "sem_timedwait() timed out\n"
464 msgstr ""
465 "$B< ./a.out 2 3>\n"
466 "About to call sem_timedwait()\n"
467 "sem_post() из обработчика\n"
468 "sem_timedwait() выполнена успешно\n"
469 "$B< ./a.out 2 1>\n"
470 "About to call sem_timedwait()\n"
471 "истекло время ожидания sem_timedwait()\n"
472
473 #. type: SS
474 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
475 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
476 #, no-wrap
477 msgid "Program source"
478 msgstr "Исходный код программы"
479
480 #. type: Plain text
481 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
482 #: opensuse-tumbleweed
483 #, no-wrap
484 msgid ""
485 "#include E<lt>err.hE<gt>\n"
486 "#include E<lt>errno.hE<gt>\n"
487 "#include E<lt>semaphore.hE<gt>\n"
488 "#include E<lt>signal.hE<gt>\n"
489 "#include E<lt>stdio.hE<gt>\n"
490 "#include E<lt>stdlib.hE<gt>\n"
491 "#include E<lt>time.hE<gt>\n"
492 "#include E<lt>unistd.hE<gt>\n"
493 "\\&\n"
494 "#include E<lt>assert.hE<gt>\n"
495 "\\&\n"
496 "sem_t sem;\n"
497 "\\&\n"
498 "static void\n"
499 "handler(int sig)\n"
500 "{\n"
501 " write(STDOUT_FILENO, \"sem_post() from handler\\[rs]n\", 24);\n"
502 " if (sem_post(&sem) == -1) {\n"
503 " write(STDERR_FILENO, \"sem_post() failed\\[rs]n\", 18);\n"
504 " _exit(EXIT_FAILURE);\n"
505 " }\n"
506 "}\n"
507 "\\&\n"
508 "int\n"
509 "main(int argc, char *argv[])\n"
510 "{\n"
511 " struct sigaction sa;\n"
512 " struct timespec ts;\n"
513 " int s;\n"
514 "\\&\n"
515 " if (argc != 3) {\n"
516 " fprintf(stderr, \"Usage: %s E<lt>alarm-secsE<gt> E<lt>wait-secsE<gt>\\[rs]n\",\n"
517 " argv[0]);\n"
518 " exit(EXIT_FAILURE);\n"
519 " }\n"
520 "\\&\n"
521 " if (sem_init(&sem, 0, 0) == -1)\n"
522 " err(EXIT_FAILURE, \"sem_init\");\n"
523 "\\&\n"
524 " /* Establish SIGALRM handler; set alarm timer using argv[1]. */\n"
525 "\\&\n"
526 " sa.sa_handler = handler;\n"
527 " sigemptyset(&sa.sa_mask);\n"
528 " sa.sa_flags = 0;\n"
529 " if (sigaction(SIGALRM, &sa, NULL) == -1)\n"
530 " err(EXIT_FAILURE, \"sigaction\");\n"
531 "\\&\n"
532 " alarm(atoi(argv[1]));\n"
533 "\\&\n"
534 " /* Calculate relative interval as current time plus\n"
535 " number of seconds given argv[2]. */\n"
536 "\\&\n"
537 " if (clock_gettime(CLOCK_REALTIME, &ts) == -1)\n"
538 " err(EXIT_FAILURE, \"clock_gettime\");\n"
539 "\\&\n"
540 " ts.tv_sec += atoi(argv[2]);\n"
541 "\\&\n"
542 " printf(\"%s() about to call sem_timedwait()\\[rs]n\", __func__);\n"
543 " while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR)\n"
544 " continue; /* Restart if interrupted by handler. */\n"
545 "\\&\n"
546 " /* Check what happened. */\n"
547 "\\&\n"
548 " if (s == -1) {\n"
549 " if (errno == ETIMEDOUT)\n"
550 " printf(\"sem_timedwait() timed out\\[rs]n\");\n"
551 " else\n"
552 " perror(\"sem_timedwait\");\n"
553 " } else\n"
554 " printf(\"sem_timedwait() succeeded\\[rs]n\");\n"
555 "\\&\n"
556 " exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE);\n"
557 "}\n"
558 msgstr ""
559
560 #. SRC END
561 #. type: SH
562 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
563 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
564 #, no-wrap
565 msgid "SEE ALSO"
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 #, fuzzy
572 #| msgid ""
573 #| "B<clock_gettime>(2), B<sem_getvalue>(3), B<sem_post>(3), "
574 #| "B<sem_overview>(7), B<time>(7)"
575 msgid ""
576 "B<clock_gettime>(2), B<sem_getvalue>(3), B<sem_post>(3), B<timespec>(3), "
577 "B<sem_overview>(7), B<time>(7)"
578 msgstr ""
579 "B<clock_gettime>(2), B<sem_getvalue>(3), B<sem_post>(3), B<sem_overview>(7), "
580 "B<time>(7)"
581
582 #. type: TH
583 #: debian-trixie
584 #, no-wrap
585 msgid "2024-06-15"
586 msgstr "15 июня 2024 г."
587
588 #. type: TH
589 #: debian-trixie
590 #, no-wrap
591 msgid "Linux man-pages 6.9.1"
592 msgstr "Страницы руководства Linux 6.9.1"
593
594 #. type: Plain text
595 #: debian-trixie
596 msgid "POSIX threads library (I<libpthread>, I<-lpthread>)"
597 msgstr "Библиотека потоков POSIX (I<libpthread>, I<-lpthread>)"
598
599 #. type: Plain text
600 #: debian-trixie fedora-44 fedora-rawhide
601 #, no-wrap
602 msgid ""
603 "#include E<lt>errno.hE<gt>\n"
604 "#include E<lt>semaphore.hE<gt>\n"
605 "#include E<lt>signal.hE<gt>\n"
606 "#include E<lt>stdio.hE<gt>\n"
607 "#include E<lt>stdlib.hE<gt>\n"
608 "#include E<lt>time.hE<gt>\n"
609 "#include E<lt>unistd.hE<gt>\n"
610 "\\&\n"
611 "#include E<lt>assert.hE<gt>\n"
612 "\\&\n"
613 "sem_t sem;\n"
614 "\\&\n"
615 "#define handle_error(msg) \\[rs]\n"
616 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
617 "\\&\n"
618 "static void\n"
619 "handler(int sig)\n"
620 "{\n"
621 " write(STDOUT_FILENO, \"sem_post() from handler\\[rs]n\", 24);\n"
622 " if (sem_post(&sem) == -1) {\n"
623 " write(STDERR_FILENO, \"sem_post() failed\\[rs]n\", 18);\n"
624 " _exit(EXIT_FAILURE);\n"
625 " }\n"
626 "}\n"
627 "\\&\n"
628 "int\n"
629 "main(int argc, char *argv[])\n"
630 "{\n"
631 " struct sigaction sa;\n"
632 " struct timespec ts;\n"
633 " int s;\n"
634 "\\&\n"
635 " if (argc != 3) {\n"
636 " fprintf(stderr, \"Usage: %s E<lt>alarm-secsE<gt> E<lt>wait-secsE<gt>\\[rs]n\",\n"
637 " argv[0]);\n"
638 " exit(EXIT_FAILURE);\n"
639 " }\n"
640 "\\&\n"
641 " if (sem_init(&sem, 0, 0) == -1)\n"
642 " handle_error(\"sem_init\");\n"
643 "\\&\n"
644 " /* Establish SIGALRM handler; set alarm timer using argv[1]. */\n"
645 "\\&\n"
646 " sa.sa_handler = handler;\n"
647 " sigemptyset(&sa.sa_mask);\n"
648 " sa.sa_flags = 0;\n"
649 " if (sigaction(SIGALRM, &sa, NULL) == -1)\n"
650 " handle_error(\"sigaction\");\n"
651 "\\&\n"
652 " alarm(atoi(argv[1]));\n"
653 "\\&\n"
654 " /* Calculate relative interval as current time plus\n"
655 " number of seconds given argv[2]. */\n"
656 "\\&\n"
657 " if (clock_gettime(CLOCK_REALTIME, &ts) == -1)\n"
658 " handle_error(\"clock_gettime\");\n"
659 "\\&\n"
660 " ts.tv_sec += atoi(argv[2]);\n"
661 "\\&\n"
662 " printf(\"%s() about to call sem_timedwait()\\[rs]n\", __func__);\n"
663 " while ((s = sem_timedwait(&sem, &ts)) == -1 && errno == EINTR)\n"
664 " continue; /* Restart if interrupted by handler. */\n"
665 "\\&\n"
666 " /* Check what happened. */\n"
667 "\\&\n"
668 " if (s == -1) {\n"
669 " if (errno == ETIMEDOUT)\n"
670 " printf(\"sem_timedwait() timed out\\[rs]n\");\n"
671 " else\n"
672 " perror(\"sem_timedwait\");\n"
673 " } else\n"
674 " printf(\"sem_timedwait() succeeded\\[rs]n\");\n"
675 "\\&\n"
676 " exit((s == 0) ? EXIT_SUCCESS : EXIT_FAILURE);\n"
677 "}\n"
678 msgstr ""
679
680 #. type: TH
681 #: fedora-44 fedora-rawhide
682 #, no-wrap
683 msgid "2024-07-23"
684 msgstr "23 июля 2024 г."
685
686 #. type: TH
687 #: fedora-44 fedora-rawhide
688 #, no-wrap
689 msgid "Linux man-pages 6.13"
690 msgstr "Страницы руководства Linux 6.13"
691
692 #. type: TH
693 #: mageia-cauldron
694 #, no-wrap
695 msgid "Linux man-pages 6.17"
696 msgstr "Страницы руководства Linux 6.17"
697
698 #. type: TH
699 #: opensuse-leap-16-1 opensuse-tumbleweed
700 #, no-wrap
701 msgid "Linux man-pages (unreleased)"
702 msgstr "Страницы руководства Linux (не выпущены)"