Debian Codegraph @

po/fr/man3/pthread_cleanup_push.3.po

raw
1 # French translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 # Christophe Blaess <https://www.blaess.fr/christophe/>, 1996-2003.
5 # Stéphan Rafin <[email protected]>, 2002.
6 # Thierry Vignaud <[email protected]>, 1999, 2002.
7 # François Micaux, 2002.
8 # Alain Portal <[email protected]>, 2003-2008.
9 # Jean-Philippe Guérard <[email protected]>, 2005-2006.
10 # Jean-Luc Coulon (f5ibh) <[email protected]>, 2006-2007.
11 # Julien Cristau <[email protected]>, 2006-2007.
12 # Thomas Huriaux <[email protected]>, 2006-2008.
13 # Nicolas François <[email protected]>, 2006-2008.
14 # Florentin Duneau <[email protected]>, 2006-2010.
15 # Simon Paillard <[email protected]>, 2006.
16 # Denis Barbier <[email protected]>, 2006, 2010.
17 # David Prévot <[email protected]>, 2010, 2012.
18 # Frédéric Hantrais <[email protected]>, 2013, 2014.
19 # Jean-Pierre Giraud <[email protected]>, 2023-2024.
20 msgid ""
21 msgstr ""
22 "Project-Id-Version: manpages-l10n 4.22.0\n"
23 "POT-Creation-Date: 2026-06-05 06:38+0200\n"
24 "PO-Revision-Date: 2024-04-20 13:02+0200\n"
25 "Last-Translator: Jean-Pierre Giraud <[email protected]>\n"
26 "Language-Team: French <[email protected]>\n"
27 "Language: fr\n"
28 "MIME-Version: 1.0\n"
29 "Content-Type: text/plain; charset=UTF-8\n"
30 "Content-Transfer-Encoding: 8bit\n"
31 "Plural-Forms: nplurals=2; plural=n > 1;\n"
32 "X-Generator: Lokalize 22.12.3\n"
33
34 #. type: TH
35 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
36 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
37 #, no-wrap
38 msgid "pthread_cleanup_push"
39 msgstr "pthread_cleanup_push"
40
41 #. type: TH
42 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
43 #: opensuse-tumbleweed
44 #, no-wrap
45 msgid "2025-08-20"
46 msgstr "20 août 2025"
47
48 #. type: TH
49 #: archlinux debian-unstable
50 #, no-wrap
51 msgid "Linux man-pages 6.18"
52 msgstr "Pages du manuel de Linux 6.18"
53
54 #. type: SH
55 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
56 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
57 #, no-wrap
58 msgid "NAME"
59 msgstr "NOM"
60
61 #. type: Plain text
62 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
63 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
64 msgid ""
65 "pthread_cleanup_push, pthread_cleanup_pop - push and pop thread cancelation "
66 "clean-up handlers"
67 msgstr ""
68 "pthread_cleanup_push, pthread_cleanup_pop — Empiler et dépiler des "
69 "gestionnaires de nettoyage de threads"
70
71 #. type: SH
72 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
73 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
74 #, no-wrap
75 msgid "LIBRARY"
76 msgstr "BIBLIOTHÈQUE"
77
78 #. type: Plain text
79 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
80 #: opensuse-leap-16-1 opensuse-tumbleweed
81 msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)"
82 msgstr "Bibliothèque de threads POSIX (I<libpthread>,\\ I<-lpthread>)"
83
84 #. type: SH
85 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
86 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
87 #, no-wrap
88 msgid "SYNOPSIS"
89 msgstr "SYNOPSIS"
90
91 #. type: Plain text
92 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
93 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
94 #, no-wrap
95 msgid "B<#include E<lt>pthread.hE<gt>>\n"
96 msgstr "B<#include E<lt>pthread.hE<gt>>\n"
97
98 #. type: Plain text
99 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
100 #: opensuse-leap-16-1 opensuse-tumbleweed
101 #, fuzzy, no-wrap
102 #| msgid ""
103 #| "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *), void *>I<arg>B<);>\n"
104 #| "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
105 msgid ""
106 "B<void pthread_cleanup_push(typeof(void (void *)) *>I<routine>B<, void *>I<arg>B<);>\n"
107 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
108 msgstr ""
109 "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *), void *>I<arg>B<);>\n"
110 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
111
112 #. type: SH
113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
115 #, no-wrap
116 msgid "DESCRIPTION"
117 msgstr "DESCRIPTION"
118
119 #. type: Plain text
120 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
121 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
122 msgid ""
123 "These functions manipulate the calling thread's stack of thread-cancelation "
124 "clean-up handlers. A clean-up handler is a function that is automatically "
125 "executed when a thread is canceled (or in various other circumstances "
126 "described below); it might, for example, unlock a mutex so that it becomes "
127 "available to other threads in the process."
128 msgstr ""
129 "Ces fonctions manipulent la pile de gestionnaires de nettoyage du thread "
130 "appelant. Un gestionnaire de nettoyage est une fonction qui est "
131 "automatiquement exécutée quand un thread est annulé (ou dans d'autres "
132 "circonstances, décrites ci-dessous). Il peut, par exemple, déverrouiller un "
133 "mutex pour le rendre disponible aux autres threads du processus."
134
135 #. type: Plain text
136 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
137 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
138 msgid ""
139 "The B<pthread_cleanup_push>() function pushes I<routine> onto the top of "
140 "the stack of clean-up handlers. When I<routine> is later invoked, it will "
141 "be given I<arg> as its argument."
142 msgstr ""
143 "La fonction B<pthread_cleanup_push>() empile I<routine> au sommet de la pile "
144 "des gestionnaires de nettoyage. Quand I<routine> sera appelée "
145 "ultérieurement, I<arg> sera passé en argument."
146
147 #. type: Plain text
148 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
149 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
150 msgid ""
151 "The B<pthread_cleanup_pop>() function removes the routine at the top of the "
152 "stack of clean-up handlers, and optionally executes it if I<execute> is "
153 "nonzero."
154 msgstr ""
155 "La fonction B<pthread_cleanup_pop>() dépile la routine au sommet de la pile "
156 "des gestionnaires de nettoyage et éventuellement l'exécute si l'argument "
157 "I<execute> est non nul."
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 "A cancelation clean-up handler is popped from the stack and executed in the "
164 "following circumstances:"
165 msgstr ""
166 "Un gestionnaire de nettoyage est dépilé et exécuté dans les circonstances "
167 "suivantes\\ :"
168
169 #. type: IP
170 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
171 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
172 #, no-wrap
173 msgid "\\[bu]"
174 msgstr "-"
175
176 #. type: Plain text
177 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
178 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
179 msgid ""
180 "When a thread is canceled, all of the stacked clean-up handlers are popped "
181 "and executed in the reverse of the order in which they were pushed onto the "
182 "stack."
183 msgstr ""
184 "Quand un thread est annulé, tous les gestionnaires de nettoyage empilés sont "
185 "dépilés et exécutés dans l'ordre inverse dans lequel ils ont été empilés."
186
187 #. type: Plain text
188 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
189 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
190 msgid ""
191 "When a thread terminates by calling B<pthread_exit>(3), all clean-up "
192 "handlers are executed as described in the preceding point. (Clean-up "
193 "handlers are I<not> called if the thread terminates by performing a "
194 "I<return> from the thread start function.)"
195 msgstr ""
196 "Quand un thread se termine en appelant B<pthread_exit>(3), tous les "
197 "gestionnaires de nettoyage sont exécutés comme décrit dans le point "
198 "précédent. Il faut noter que les gestionnaires de nettoyage ne sont I<pas> "
199 "appelés si le thread se termine par un I<return> depuis la fonction de "
200 "démarrage du thread."
201
202 #. type: Plain text
203 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
204 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
205 msgid ""
206 "When a thread calls B<pthread_cleanup_pop>() with a nonzero I<execute> "
207 "argument, the top-most clean-up handler is popped and executed."
208 msgstr ""
209 "Quand un thread appelle B<pthread_cleanup_pop>() avec un argument I<execute> "
210 "non nul, le gestionnaire de nettoyage au sommet de la pile est dépilé et "
211 "exécuté."
212
213 #. type: Plain text
214 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
215 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
216 msgid ""
217 "POSIX.1 permits B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() to "
218 "be implemented as macros that expand to text containing \\[aq]B<{>\\[aq] and "
219 "\\[aq]B<}>\\[aq], respectively. For this reason, the caller must ensure "
220 "that calls to these functions are paired within the same function, and at "
221 "the same lexical nesting level. (In other words, a clean-up handler is "
222 "established only during the execution of a specified section of code.)"
223 msgstr ""
224 "POSIX.1 autorise B<pthread_cleanup_push>() et B<pthread_cleanup_pop>() à "
225 "être implémentées comme des macros qui sont développées en du texte "
226 "contenant «\\ B<{>\\ » et «\\ B<}>\\ » respectivement. Pour cette raison, "
227 "l'appelant doit s'assurer que les appels à ces fonctions sont appariés à "
228 "l'intérieur d'une même fonction et au même niveau d'imbriquement lexical. En "
229 "d'autres termes, un gestionnaire de nettoyage n'est établi que pendant "
230 "l'exécution d'une partie spécifique de code."
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 "Calling B<longjmp>(3) (B<siglongjmp>(3)) produces undefined results if any "
237 "call has been made to B<pthread_cleanup_push>() or "
238 "B<pthread_cleanup_pop>() without the matching call of the pair since the "
239 "jump buffer was filled by B<setjmp>(3) (B<sigsetjmp>(3)). Likewise, "
240 "calling B<longjmp>(3) (B<siglongjmp>(3)) from inside a clean-up handler "
241 "produces undefined results unless the jump buffer was also filled by "
242 "B<setjmp>(3) (B<sigsetjmp>(3)) inside the handler."
243 msgstr ""
244 "Un appel à B<longjmp>(3) (resp. B<siglongjmp>(3)) produit des résultats "
245 "indéfinis si un appel à B<pthread_cleanup_push>() ou "
246 "B<pthread_cleanup_pop>() a été réalisé sans l'appel correspondant de la "
247 "paire si le tampon de saut a été rempli par B<setjmp>(3) (resp. "
248 "B<sigsetjmp>(3)). De la même manière, un appel à B<longjmp>(3) (resp. "
249 "B<siglongjmp>(3)) depuis un gestionnaire de nettoyage entraine des "
250 "résultats indéfinis, sauf si le tampon de saut a lui aussi été rempli dans "
251 "B<setjmp>(3) (resp. B<sigsetjmp>(3)) à l'intérieur du gestionnaire."
252
253 #. type: SH
254 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
255 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
256 #, no-wrap
257 msgid "RETURN VALUE"
258 msgstr "VALEUR RENVOYÉE"
259
260 #. type: Plain text
261 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
262 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
263 msgid "These functions do not return a value."
264 msgstr "Ces fonctions ne renvoient aucune valeur."
265
266 #. type: SH
267 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
268 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
269 #, no-wrap
270 msgid "ERRORS"
271 msgstr "ERREURS"
272
273 #. type: Plain text
274 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
275 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
276 msgid "There are no errors."
277 msgstr "Il n'y a pas d'erreur."
278
279 #. type: SH
280 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
281 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
282 #, no-wrap
283 msgid "ATTRIBUTES"
284 msgstr "ATTRIBUTS"
285
286 #. type: Plain text
287 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
288 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
289 msgid ""
290 "For an explanation of the terms used in this section, see B<attributes>(7)."
291 msgstr ""
292 "Pour une explication des termes utilisés dans cette section, consulter "
293 "B<attributes>(7)."
294
295 #. type: tbl table
296 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
297 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
298 #, no-wrap
299 msgid "Interface"
300 msgstr "Interface"
301
302 #. type: tbl table
303 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
304 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
305 #, no-wrap
306 msgid "Attribute"
307 msgstr "Attribut"
308
309 #. type: tbl table
310 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
311 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
312 #, no-wrap
313 msgid "Value"
314 msgstr "Valeur"
315
316 #. type: tbl table
317 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
318 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
319 #, no-wrap
320 msgid ".na\n"
321 msgstr ".na\n"
322
323 #. type: tbl table
324 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
325 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
326 #, no-wrap
327 msgid ".nh\n"
328 msgstr ".nh\n"
329
330 #. type: tbl table
331 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
332 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
333 #, no-wrap
334 msgid ""
335 "B<pthread_cleanup_push>(),\n"
336 "B<pthread_cleanup_pop>()"
337 msgstr ""
338 "B<pthread_cleanup_push>(),\n"
339 "B<pthread_cleanup_pop>()"
340
341 #. type: tbl table
342 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
343 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
344 #, no-wrap
345 msgid "Thread safety"
346 msgstr "Sécurité des threads"
347
348 #. type: tbl table
349 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
350 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
351 #, no-wrap
352 msgid "MT-Safe"
353 msgstr "MT-Safe"
354
355 #. type: SH
356 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
357 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
358 #, no-wrap
359 msgid "VERSIONS"
360 msgstr "VERSIONS"
361
362 #. type: Plain text
363 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
364 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
365 msgid ""
366 "On glibc, the B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() "
367 "functions I<are> implemented as macros that expand to text containing \\"
368 "[aq]B<{>\\[aq] and \\[aq]B<}>\\[aq], respectively. This means that "
369 "variables declared within the scope of paired calls to these functions will "
370 "be visible within only that scope."
371 msgstr ""
372 "Sous la glibc, les fonctions B<pthread_cleanup_push>() et "
373 "B<pthread_cleanup_pop>() I<sont> implémentées comme des macros qui sont "
374 "développées en du texte contenant «\\ B<{>\\ » et «\\ B<}>\\ » "
375 "respectivement. Cela signifie que les variables déclarées entre les appels "
376 "appariés à ces fonctions ne seront visible qu'à l'intérieur de cet "
377 "intervalle."
378
379 #. The text was actually added in the 2004 TC2
380 #. type: Plain text
381 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
382 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
383 msgid ""
384 "POSIX.1 says that the effect of using I<return>, I<break>, I<continue>, or "
385 "I<goto> to prematurely leave a block bracketed B<pthread_cleanup_push>() "
386 "and B<pthread_cleanup_pop>() is undefined. Portable applications should "
387 "avoid doing this."
388 msgstr ""
389 "POSIX.1 indique qu'utiliser I<return>, I<break>, I<continue> ou I<goto> pour "
390 "quitter prématurément un bloc compris entre B<pthread_cleanup_push>() et "
391 "B<pthread_cleanup_pop>() entraîne un comportement indéfini. Les applications "
392 "portables doivent l'éviter."
393
394 #. type: SH
395 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
396 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
397 #, no-wrap
398 msgid "STANDARDS"
399 msgstr "NORMES"
400
401 #. type: Plain text
402 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
403 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
404 msgid "POSIX.1-2008."
405 msgstr "POSIX.1-2008."
406
407 #. type: SH
408 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
409 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
410 #, no-wrap
411 msgid "HISTORY"
412 msgstr "HISTORIQUE"
413
414 #. type: Plain text
415 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
416 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
417 msgid "POSIX.1-2001. glibc 2.0."
418 msgstr "POSIX.1-2001. glibc 2.0."
419
420 #. type: SH
421 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
422 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
423 #, no-wrap
424 msgid "EXAMPLES"
425 msgstr "EXEMPLES"
426
427 #. type: Plain text
428 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
429 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
430 msgid ""
431 "The program below provides a simple example of the use of the functions "
432 "described in this page. The program creates a thread that executes a loop "
433 "bracketed by B<pthread_cleanup_push>() and B<pthread_cleanup_pop>(). This "
434 "loop increments a global variable, I<cnt>, once each second. Depending on "
435 "what command-line arguments are supplied, the main thread sends the other "
436 "thread a cancelation request, or sets a global variable that causes the "
437 "other thread to exit its loop and terminate normally (by doing a I<return>)."
438 msgstr ""
439 "Le programme ci-dessous fournit un exemple simple de l'utilisation des "
440 "fonctions décrites dans cette page. Le programme crée un thread qui exécute "
441 "une boucle comprise entre des appels à B<pthread_cleanup_push>() et "
442 "B<pthread_cleanup_pop>(). Cette boucle incrémente une variable globale, "
443 "I<cnt>, à chaque seconde. En fonction des arguments fournis sur la ligne de "
444 "commande, le thread principal envoie une requête d'annulation à l'autre "
445 "thread, ou définit une variable globale qui fait que l'autre thread quitte "
446 "sa boucle et se termine normalement (avec un I<return>)."
447
448 #. type: Plain text
449 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
450 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
451 msgid ""
452 "In the following shell session, the main thread sends a cancelation request "
453 "to the other thread:"
454 msgstr ""
455 "Dans la session d'interpréteur de commande ci-dessous, le thread principal "
456 "envoie une requête d'annulation à l'autre thread\\ :"
457
458 #. type: Plain text
459 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
460 #: opensuse-tumbleweed
461 #, fuzzy, no-wrap
462 #| msgid ""
463 #| "$ B<./a.out>\n"
464 #| "New thread started\n"
465 #| "cnt = 0\n"
466 #| "cnt = 1\n"
467 #| "Canceling thread\n"
468 #| "Called clean-up handler\n"
469 #| "Thread was canceled; cnt = 0\n"
470 msgid ""
471 "$B< ./a.out>;\n"
472 "New thread started\n"
473 "cnt = 0\n"
474 "cnt = 1\n"
475 "Canceling thread\n"
476 "Called clean-up handler\n"
477 "Thread was canceled; cnt = 0\n"
478 msgstr ""
479 "$ B<./a.out>\n"
480 "Nouveau thread démarré\n"
481 "cnt = 0\n"
482 "cnt = 1\n"
483 "Annulation du thread\n"
484 "Gestionnaire de nettoyage appelé\n"
485 "Le thread a été annulé ; cnt = 0\n"
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 "From the above, we see that the thread was canceled, and that the "
492 "cancelation clean-up handler was called and it reset the value of the global "
493 "variable I<cnt> to 0."
494 msgstr ""
495 "Dans la sortie, nous voyons que le thread a été annulé et que le "
496 "gestionnaire de nettoyage a été appelé et a remis la valeur de la variable "
497 "globale I<cnt> à 0."
498
499 #. type: Plain text
500 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
501 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
502 msgid ""
503 "In the next run, the main program sets a global variable that causes other "
504 "thread to terminate normally:"
505 msgstr ""
506 "Lors de l'exécution suivante, le programme principal définit une variable "
507 "globale qui fait que l'autre thread se termine normalement\\ :"
508
509 #. type: Plain text
510 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
511 #: opensuse-tumbleweed
512 #, fuzzy, no-wrap
513 #| msgid ""
514 #| "$ B<./a.out x>\n"
515 #| "New thread started\n"
516 #| "cnt = 0\n"
517 #| "cnt = 1\n"
518 #| "Thread terminated normally; cnt = 2\n"
519 msgid ""
520 "$B< ./a.out x>;\n"
521 "New thread started\n"
522 "cnt = 0\n"
523 "cnt = 1\n"
524 "Thread terminated normally; cnt = 2\n"
525 msgstr ""
526 "$ B<./a.out x>\n"
527 "Nouveau thread démarré\n"
528 "cnt = 0\n"
529 "cnt = 1\n"
530 "Thread terminé normalement ; cnt = 2\n"
531
532 #. type: Plain text
533 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
534 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
535 msgid ""
536 "From the above, we see that the clean-up handler was not executed (because "
537 "I<cleanup_pop_arg> was 0), and therefore the value of I<cnt> was not reset."
538 msgstr ""
539 "Dans la sortie, nous voyons que le gestionnaire de nettoyage n'a pas été "
540 "appelé (car I<cleanup_pop_arg> vaut 0), et la variable I<cnt> n'a pas été "
541 "réinitialisée."
542
543 #. type: Plain text
544 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
545 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
546 msgid ""
547 "In the next run, the main program sets a global variable that causes the "
548 "other thread to terminate normally, and supplies a nonzero value for "
549 "I<cleanup_pop_arg>:"
550 msgstr ""
551 "Lors de l'exécution suivante, le programme principal définit une variable "
552 "globale qui fait que l'autre thread se termine normalement, et fournit une "
553 "valeur non-nulle à I<cleanup_pop_arg>\\ :"
554
555 #. type: Plain text
556 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
557 #: opensuse-tumbleweed
558 #, fuzzy, no-wrap
559 #| msgid ""
560 #| "$ B<./a.out x 1>\n"
561 #| "New thread started\n"
562 #| "cnt = 0\n"
563 #| "cnt = 1\n"
564 #| "Called clean-up handler\n"
565 #| "Thread terminated normally; cnt = 0\n"
566 msgid ""
567 "$B< ./a.out x 1>;\n"
568 "New thread started\n"
569 "cnt = 0\n"
570 "cnt = 1\n"
571 "Called clean-up handler\n"
572 "Thread terminated normally; cnt = 0\n"
573 msgstr ""
574 "$ B<./a.out x 1>\n"
575 "Nouveau thread démarré\n"
576 "cnt = 0\n"
577 "cnt = 1\n"
578 "Gestionnaire de nettoyage appelé\n"
579 "Thread terminé normalement ; cnt = 0\n"
580
581 #. type: Plain text
582 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
583 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
584 msgid ""
585 "In the above, we see that although the thread was not canceled, the clean-up "
586 "handler was executed, because the argument given to "
587 "B<pthread_cleanup_pop>() was nonzero."
588 msgstr ""
589 "Dans la sortie, nous voyons que bien que le thread n'ait pas été annulé, le "
590 "gestionnaire de nettoyage a été appelé, car l'argument fourni à "
591 "B<pthread_cleanup_pop> n'était pas nul."
592
593 #. type: SS
594 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
595 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
596 #, no-wrap
597 msgid "Program source"
598 msgstr "Source du programme"
599
600 #. type: Plain text
601 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
602 #: opensuse-tumbleweed
603 #, fuzzy, no-wrap
604 #| msgid ""
605 #| "#include E<lt>errno.hE<gt>\n"
606 #| "#include E<lt>pthread.hE<gt>\n"
607 #| "#include E<lt>stdio.hE<gt>\n"
608 #| "#include E<lt>stdlib.hE<gt>\n"
609 #| "#include E<lt>sys/types.hE<gt>\n"
610 #| "#include E<lt>unistd.hE<gt>\n"
611 #| "\\&\n"
612 #| "#define handle_error_en(en, msg) \\e\n"
613 #| " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
614 #| "\\&\n"
615 #| "static int done = 0;\n"
616 #| "static int cleanup_pop_arg = 0;\n"
617 #| "static int cnt = 0;\n"
618 #| "\\&\n"
619 #| "static void\n"
620 #| "cleanup_handler(void *arg)\n"
621 #| "{\n"
622 #| " printf(\"Called clean-up handler\\en\");\n"
623 #| " cnt = 0;\n"
624 #| "}\n"
625 #| "\\&\n"
626 #| "static void *\n"
627 #| "thread_start(void *arg)\n"
628 #| "{\n"
629 #| " time_t curr;\n"
630 #| "\\&\n"
631 #| " printf(\"New thread started\\en\");\n"
632 #| "\\&\n"
633 #| " pthread_cleanup_push(cleanup_handler, NULL);\n"
634 #| "\\&\n"
635 #| " curr = time(NULL);\n"
636 #| "\\&\n"
637 #| " while (!done) {\n"
638 #| " pthread_testcancel(); /* A cancelation point */\n"
639 #| " if (curr E<lt> time(NULL)) {\n"
640 #| " curr = time(NULL);\n"
641 #| " printf(\"cnt = %d\\en\", cnt); /* A cancelation point */\n"
642 #| " cnt++;\n"
643 #| " }\n"
644 #| " }\n"
645 #| "\\&\n"
646 #| " pthread_cleanup_pop(cleanup_pop_arg);\n"
647 #| " return NULL;\n"
648 #| "}\n"
649 #| "\\&\n"
650 #| "int\n"
651 #| "main(int argc, char *argv[])\n"
652 #| "{\n"
653 #| " pthread_t thr;\n"
654 #| " int s;\n"
655 #| " void *res;\n"
656 #| "\\&\n"
657 #| " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
658 #| " if (s != 0)\n"
659 #| " handle_error_en(s, \"pthread_create\");\n"
660 #| "\\&\n"
661 #| " sleep(2); /* Allow new thread to run a while */\n"
662 #| "\\&\n"
663 #| " if (argc E<gt> 1) {\n"
664 #| " if (argc E<gt> 2)\n"
665 #| " cleanup_pop_arg = atoi(argv[2]);\n"
666 #| " done = 1;\n"
667 #| "\\&\n"
668 #| " } else {\n"
669 #| " printf(\"Canceling thread\\en\");\n"
670 #| " s = pthread_cancel(thr);\n"
671 #| " if (s != 0)\n"
672 #| " handle_error_en(s, \"pthread_cancel\");\n"
673 #| " }\n"
674 #| "\\&\n"
675 #| " s = pthread_join(thr, &res);\n"
676 #| " if (s != 0)\n"
677 #| " handle_error_en(s, \"pthread_join\");\n"
678 #| "\\&\n"
679 #| " if (res == PTHREAD_CANCELED)\n"
680 #| " printf(\"Thread was canceled; cnt = %d\\en\", cnt);\n"
681 #| " else\n"
682 #| " printf(\"Thread terminated normally; cnt = %d\\en\", cnt);\n"
683 #| " exit(EXIT_SUCCESS);\n"
684 #| "}\n"
685 msgid ""
686 "#include E<lt>err.hE<gt>\n"
687 "#include E<lt>errno.hE<gt>\n"
688 "#include E<lt>pthread.hE<gt>\n"
689 "#include E<lt>stdio.hE<gt>\n"
690 "#include E<lt>stdlib.hE<gt>\n"
691 "#include E<lt>sys/types.hE<gt>\n"
692 "#include E<lt>unistd.hE<gt>\n"
693 "\\&\n"
694 "static int done = 0;\n"
695 "static int cleanup_pop_arg = 0;\n"
696 "static int cnt = 0;\n"
697 "\\&\n"
698 "static void\n"
699 "cleanup_handler(void *arg)\n"
700 "{\n"
701 " printf(\"Called clean-up handler\\[rs]n\");\n"
702 " cnt = 0;\n"
703 "}\n"
704 "\\&\n"
705 "static void *\n"
706 "thread_start(void *arg)\n"
707 "{\n"
708 " time_t curr;\n"
709 "\\&\n"
710 " printf(\"New thread started\\[rs]n\");\n"
711 "\\&\n"
712 " pthread_cleanup_push(cleanup_handler, NULL);\n"
713 "\\&\n"
714 " curr = time(NULL);\n"
715 "\\&\n"
716 " while (!done) {\n"
717 " pthread_testcancel(); /* A cancelation point */\n"
718 " if (curr E<lt> time(NULL)) {\n"
719 " curr = time(NULL);\n"
720 " printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n"
721 " cnt++;\n"
722 " }\n"
723 " }\n"
724 "\\&\n"
725 " pthread_cleanup_pop(cleanup_pop_arg);\n"
726 " return NULL;\n"
727 "}\n"
728 "\\&\n"
729 "int\n"
730 "main(int argc, char *argv[])\n"
731 "{\n"
732 " pthread_t thr;\n"
733 " int s;\n"
734 " void *res;\n"
735 "\\&\n"
736 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
737 " if (s != 0)\n"
738 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
739 "\\&\n"
740 " sleep(2); /* Allow new thread to run a while */\n"
741 "\\&\n"
742 " if (argc E<gt> 1) {\n"
743 " if (argc E<gt> 2)\n"
744 " cleanup_pop_arg = atoi(argv[2]);\n"
745 " done = 1;\n"
746 "\\&\n"
747 " } else {\n"
748 " printf(\"Canceling thread\\[rs]n\");\n"
749 " s = pthread_cancel(thr);\n"
750 " if (s != 0)\n"
751 " errc(EXIT_FAILURE, s, \"pthread_cancel\");\n"
752 " }\n"
753 "\\&\n"
754 " s = pthread_join(thr, &res);\n"
755 " if (s != 0)\n"
756 " errc(EXIT_FAILURE, s, \"pthread_join\");\n"
757 "\\&\n"
758 " if (res == PTHREAD_CANCELED)\n"
759 " printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n"
760 " else\n"
761 " printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n"
762 " exit(EXIT_SUCCESS);\n"
763 "}\n"
764 msgstr ""
765 "#include E<lt>errno.hE<gt>\n"
766 "#include E<lt>pthread.hE<gt>\n"
767 "#include E<lt>stdio.hE<gt>\n"
768 "#include E<lt>stdlib.hE<gt>\n"
769 "#include E<lt>sys/types.hE<gt>\n"
770 "#include E<lt>unistd.hE<gt>\n"
771 "\\&\n"
772 "#define handle_error_en(en, msg) \\e\n"
773 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
774 "\\&\n"
775 "static int done = 0;\n"
776 "static int cleanup_pop_arg = 0;\n"
777 "static int cnt = 0;\n"
778 "\\&\n"
779 "static void\n"
780 "cleanup_handler(void *arg)\n"
781 "{\n"
782 " printf(\"Gestionnaire de nettoyage appelé\\en\");\n"
783 " cnt = 0;\n"
784 "}\n"
785 "\\&\n"
786 "static void *\n"
787 "thread_start(void *arg)\n"
788 "{\n"
789 " time_t curr;\n"
790 "\\&\n"
791 " printf(\"Nouveau thread démarré\\en\");\n"
792 "\\&\n"
793 " pthread_cleanup_push(cleanup_handler, NULL);\n"
794 "\\&\n"
795 " curr = time(NULL);\n"
796 "\\&\n"
797 " while (!done) {\n"
798 " pthread_testcancel(); /* Un point d'annulation */\n"
799 " if (curr E<lt> time(NULL)) {\n"
800 " curr = time(NULL);\n"
801 " printf(\"cnt = %d\\en\", cnt); /* Un point d'annulation */\n"
802 " cnt++;\n"
803 " }\n"
804 " }\n"
805 "\\&\n"
806 " pthread_cleanup_pop(cleanup_pop_arg);\n"
807 " return NULL;\n"
808 "}\n"
809 "\\&\n"
810 "int\n"
811 "main(int argc, char *argv[])\n"
812 "{\n"
813 " pthread_t thr;\n"
814 " int s;\n"
815 " void *res;\n"
816 "\\&\n"
817 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
818 " if (s != 0)\n"
819 " handle_error_en(s, \"pthread_create\");\n"
820 "\\&\n"
821 " sleep(2); /* Permettre l'exécution du nouveau thread quelque temps */\n"
822 "\\&\n"
823 " if (argc E<gt> 1) {\n"
824 " if (argc E<gt> 2)\n"
825 " cleanup_pop_arg = atoi(argv[2]);\n"
826 " done = 1;\n"
827 "\\&\n"
828 " } else {\n"
829 " printf(\"Annulation du thread\\en\");\n"
830 " s = pthread_cancel(thr);\n"
831 " if (s != 0)\n"
832 " handle_error_en(s, \"pthread_cancel\");\n"
833 " }\n"
834 "\\&\n"
835 " s = pthread_join(thr, &res);\n"
836 " if (s != 0)\n"
837 " handle_error_en(s, \"pthread_join\");\n"
838 "\\&\n"
839 " if (res == PTHREAD_CANCELED)\n"
840 " printf(\"Le thread a été annulé ; cnt = %d\\en\", cnt);\n"
841 " else\n"
842 " printf(\"Thread terminé normalement ; cnt = %d\\en\", cnt);\n"
843 " exit(EXIT_SUCCESS);\n"
844 "}\n"
845
846 #. SRC END
847 #. type: SH
848 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
849 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
850 #, no-wrap
851 msgid "SEE ALSO"
852 msgstr "VOIR AUSSI"
853
854 #. type: Plain text
855 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
856 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
857 msgid ""
858 "B<pthread_cancel>(3), B<pthread_cleanup_push_defer_np>(3), "
859 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
860 msgstr ""
861 "B<pthread_cancel>(3), B<pthread_cleanup_push_defer_np>(3), "
862 "B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)"
863
864 #. type: TH
865 #: debian-trixie
866 #, no-wrap
867 msgid "2024-06-15"
868 msgstr "15 juin 2024"
869
870 #. type: TH
871 #: debian-trixie
872 #, no-wrap
873 msgid "Linux man-pages 6.9.1"
874 msgstr "Pages du manuel de Linux 6.9.1"
875
876 #. type: Plain text
877 #: debian-trixie
878 msgid "POSIX threads library (I<libpthread>, I<-lpthread>)"
879 msgstr "Bibliothèque de threads POSIX (I<libpthread>, I<-lpthread>)"
880
881 #. type: Plain text
882 #: debian-trixie
883 #, no-wrap
884 msgid ""
885 "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *), void *>I<arg>B<);>\n"
886 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
887 msgstr ""
888 "B<void pthread_cleanup_push(void (*>I<routine>B<)(void *), void *>I<arg>B<);>\n"
889 "B<void pthread_cleanup_pop(int >I<execute>B<);>\n"
890
891 #. type: Plain text
892 #: debian-trixie fedora-44 fedora-rawhide
893 #, no-wrap
894 msgid ""
895 "$ B<./a.out>\n"
896 "New thread started\n"
897 "cnt = 0\n"
898 "cnt = 1\n"
899 "Canceling thread\n"
900 "Called clean-up handler\n"
901 "Thread was canceled; cnt = 0\n"
902 msgstr ""
903 "$ B<./a.out>\n"
904 "Nouveau thread démarré\n"
905 "cnt = 0\n"
906 "cnt = 1\n"
907 "Annulation du thread\n"
908 "Gestionnaire de nettoyage appelé\n"
909 "Le thread a été annulé ; cnt = 0\n"
910
911 #. type: Plain text
912 #: debian-trixie fedora-44 fedora-rawhide
913 #, no-wrap
914 msgid ""
915 "$ B<./a.out x>\n"
916 "New thread started\n"
917 "cnt = 0\n"
918 "cnt = 1\n"
919 "Thread terminated normally; cnt = 2\n"
920 msgstr ""
921 "$ B<./a.out x>\n"
922 "Nouveau thread démarré\n"
923 "cnt = 0\n"
924 "cnt = 1\n"
925 "Thread terminé normalement ; cnt = 2\n"
926
927 #. type: Plain text
928 #: debian-trixie fedora-44 fedora-rawhide
929 #, no-wrap
930 msgid ""
931 "$ B<./a.out x 1>\n"
932 "New thread started\n"
933 "cnt = 0\n"
934 "cnt = 1\n"
935 "Called clean-up handler\n"
936 "Thread terminated normally; cnt = 0\n"
937 msgstr ""
938 "$ B<./a.out x 1>\n"
939 "Nouveau thread démarré\n"
940 "cnt = 0\n"
941 "cnt = 1\n"
942 "Gestionnaire de nettoyage appelé\n"
943 "Thread terminé normalement ; cnt = 0\n"
944
945 #. type: Plain text
946 #: debian-trixie fedora-44 fedora-rawhide
947 #, fuzzy, no-wrap
948 #| msgid ""
949 #| "#include E<lt>errno.hE<gt>\n"
950 #| "#include E<lt>pthread.hE<gt>\n"
951 #| "#include E<lt>stdio.hE<gt>\n"
952 #| "#include E<lt>stdlib.hE<gt>\n"
953 #| "#include E<lt>sys/types.hE<gt>\n"
954 #| "#include E<lt>unistd.hE<gt>\n"
955 #| "\\&\n"
956 #| "#define handle_error_en(en, msg) \\e\n"
957 #| " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
958 #| "\\&\n"
959 #| "static int done = 0;\n"
960 #| "static int cleanup_pop_arg = 0;\n"
961 #| "static int cnt = 0;\n"
962 #| "\\&\n"
963 #| "static void\n"
964 #| "cleanup_handler(void *arg)\n"
965 #| "{\n"
966 #| " printf(\"Called clean-up handler\\en\");\n"
967 #| " cnt = 0;\n"
968 #| "}\n"
969 #| "\\&\n"
970 #| "static void *\n"
971 #| "thread_start(void *arg)\n"
972 #| "{\n"
973 #| " time_t curr;\n"
974 #| "\\&\n"
975 #| " printf(\"New thread started\\en\");\n"
976 #| "\\&\n"
977 #| " pthread_cleanup_push(cleanup_handler, NULL);\n"
978 #| "\\&\n"
979 #| " curr = time(NULL);\n"
980 #| "\\&\n"
981 #| " while (!done) {\n"
982 #| " pthread_testcancel(); /* A cancelation point */\n"
983 #| " if (curr E<lt> time(NULL)) {\n"
984 #| " curr = time(NULL);\n"
985 #| " printf(\"cnt = %d\\en\", cnt); /* A cancelation point */\n"
986 #| " cnt++;\n"
987 #| " }\n"
988 #| " }\n"
989 #| "\\&\n"
990 #| " pthread_cleanup_pop(cleanup_pop_arg);\n"
991 #| " return NULL;\n"
992 #| "}\n"
993 #| "\\&\n"
994 #| "int\n"
995 #| "main(int argc, char *argv[])\n"
996 #| "{\n"
997 #| " pthread_t thr;\n"
998 #| " int s;\n"
999 #| " void *res;\n"
1000 #| "\\&\n"
1001 #| " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
1002 #| " if (s != 0)\n"
1003 #| " handle_error_en(s, \"pthread_create\");\n"
1004 #| "\\&\n"
1005 #| " sleep(2); /* Allow new thread to run a while */\n"
1006 #| "\\&\n"
1007 #| " if (argc E<gt> 1) {\n"
1008 #| " if (argc E<gt> 2)\n"
1009 #| " cleanup_pop_arg = atoi(argv[2]);\n"
1010 #| " done = 1;\n"
1011 #| "\\&\n"
1012 #| " } else {\n"
1013 #| " printf(\"Canceling thread\\en\");\n"
1014 #| " s = pthread_cancel(thr);\n"
1015 #| " if (s != 0)\n"
1016 #| " handle_error_en(s, \"pthread_cancel\");\n"
1017 #| " }\n"
1018 #| "\\&\n"
1019 #| " s = pthread_join(thr, &res);\n"
1020 #| " if (s != 0)\n"
1021 #| " handle_error_en(s, \"pthread_join\");\n"
1022 #| "\\&\n"
1023 #| " if (res == PTHREAD_CANCELED)\n"
1024 #| " printf(\"Thread was canceled; cnt = %d\\en\", cnt);\n"
1025 #| " else\n"
1026 #| " printf(\"Thread terminated normally; cnt = %d\\en\", cnt);\n"
1027 #| " exit(EXIT_SUCCESS);\n"
1028 #| "}\n"
1029 msgid ""
1030 "#include E<lt>errno.hE<gt>\n"
1031 "#include E<lt>pthread.hE<gt>\n"
1032 "#include E<lt>stdio.hE<gt>\n"
1033 "#include E<lt>stdlib.hE<gt>\n"
1034 "#include E<lt>sys/types.hE<gt>\n"
1035 "#include E<lt>unistd.hE<gt>\n"
1036 "\\&\n"
1037 "#define handle_error_en(en, msg) \\[rs]\n"
1038 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
1039 "\\&\n"
1040 "static int done = 0;\n"
1041 "static int cleanup_pop_arg = 0;\n"
1042 "static int cnt = 0;\n"
1043 "\\&\n"
1044 "static void\n"
1045 "cleanup_handler(void *arg)\n"
1046 "{\n"
1047 " printf(\"Called clean-up handler\\[rs]n\");\n"
1048 " cnt = 0;\n"
1049 "}\n"
1050 "\\&\n"
1051 "static void *\n"
1052 "thread_start(void *arg)\n"
1053 "{\n"
1054 " time_t curr;\n"
1055 "\\&\n"
1056 " printf(\"New thread started\\[rs]n\");\n"
1057 "\\&\n"
1058 " pthread_cleanup_push(cleanup_handler, NULL);\n"
1059 "\\&\n"
1060 " curr = time(NULL);\n"
1061 "\\&\n"
1062 " while (!done) {\n"
1063 " pthread_testcancel(); /* A cancelation point */\n"
1064 " if (curr E<lt> time(NULL)) {\n"
1065 " curr = time(NULL);\n"
1066 " printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n"
1067 " cnt++;\n"
1068 " }\n"
1069 " }\n"
1070 "\\&\n"
1071 " pthread_cleanup_pop(cleanup_pop_arg);\n"
1072 " return NULL;\n"
1073 "}\n"
1074 "\\&\n"
1075 "int\n"
1076 "main(int argc, char *argv[])\n"
1077 "{\n"
1078 " pthread_t thr;\n"
1079 " int s;\n"
1080 " void *res;\n"
1081 "\\&\n"
1082 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
1083 " if (s != 0)\n"
1084 " handle_error_en(s, \"pthread_create\");\n"
1085 "\\&\n"
1086 " sleep(2); /* Allow new thread to run a while */\n"
1087 "\\&\n"
1088 " if (argc E<gt> 1) {\n"
1089 " if (argc E<gt> 2)\n"
1090 " cleanup_pop_arg = atoi(argv[2]);\n"
1091 " done = 1;\n"
1092 "\\&\n"
1093 " } else {\n"
1094 " printf(\"Canceling thread\\[rs]n\");\n"
1095 " s = pthread_cancel(thr);\n"
1096 " if (s != 0)\n"
1097 " handle_error_en(s, \"pthread_cancel\");\n"
1098 " }\n"
1099 "\\&\n"
1100 " s = pthread_join(thr, &res);\n"
1101 " if (s != 0)\n"
1102 " handle_error_en(s, \"pthread_join\");\n"
1103 "\\&\n"
1104 " if (res == PTHREAD_CANCELED)\n"
1105 " printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n"
1106 " else\n"
1107 " printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n"
1108 " exit(EXIT_SUCCESS);\n"
1109 "}\n"
1110 msgstr ""
1111 "#include E<lt>errno.hE<gt>\n"
1112 "#include E<lt>pthread.hE<gt>\n"
1113 "#include E<lt>stdio.hE<gt>\n"
1114 "#include E<lt>stdlib.hE<gt>\n"
1115 "#include E<lt>sys/types.hE<gt>\n"
1116 "#include E<lt>unistd.hE<gt>\n"
1117 "\\&\n"
1118 "#define handle_error_en(en, msg) \\e\n"
1119 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
1120 "\\&\n"
1121 "static int done = 0;\n"
1122 "static int cleanup_pop_arg = 0;\n"
1123 "static int cnt = 0;\n"
1124 "\\&\n"
1125 "static void\n"
1126 "cleanup_handler(void *arg)\n"
1127 "{\n"
1128 " printf(\"Gestionnaire de nettoyage appelé\\en\");\n"
1129 " cnt = 0;\n"
1130 "}\n"
1131 "\\&\n"
1132 "static void *\n"
1133 "thread_start(void *arg)\n"
1134 "{\n"
1135 " time_t curr;\n"
1136 "\\&\n"
1137 " printf(\"Nouveau thread démarré\\en\");\n"
1138 "\\&\n"
1139 " pthread_cleanup_push(cleanup_handler, NULL);\n"
1140 "\\&\n"
1141 " curr = time(NULL);\n"
1142 "\\&\n"
1143 " while (!done) {\n"
1144 " pthread_testcancel(); /* Un point d'annulation */\n"
1145 " if (curr E<lt> time(NULL)) {\n"
1146 " curr = time(NULL);\n"
1147 " printf(\"cnt = %d\\en\", cnt); /* Un point d'annulation */\n"
1148 " cnt++;\n"
1149 " }\n"
1150 " }\n"
1151 "\\&\n"
1152 " pthread_cleanup_pop(cleanup_pop_arg);\n"
1153 " return NULL;\n"
1154 "}\n"
1155 "\\&\n"
1156 "int\n"
1157 "main(int argc, char *argv[])\n"
1158 "{\n"
1159 " pthread_t thr;\n"
1160 " int s;\n"
1161 " void *res;\n"
1162 "\\&\n"
1163 " s = pthread_create(&thr, NULL, thread_start, NULL);\n"
1164 " if (s != 0)\n"
1165 " handle_error_en(s, \"pthread_create\");\n"
1166 "\\&\n"
1167 " sleep(2); /* Permettre l'exécution du nouveau thread quelque temps */\n"
1168 "\\&\n"
1169 " if (argc E<gt> 1) {\n"
1170 " if (argc E<gt> 2)\n"
1171 " cleanup_pop_arg = atoi(argv[2]);\n"
1172 " done = 1;\n"
1173 "\\&\n"
1174 " } else {\n"
1175 " printf(\"Annulation du thread\\en\");\n"
1176 " s = pthread_cancel(thr);\n"
1177 " if (s != 0)\n"
1178 " handle_error_en(s, \"pthread_cancel\");\n"
1179 " }\n"
1180 "\\&\n"
1181 " s = pthread_join(thr, &res);\n"
1182 " if (s != 0)\n"
1183 " handle_error_en(s, \"pthread_join\");\n"
1184 "\\&\n"
1185 " if (res == PTHREAD_CANCELED)\n"
1186 " printf(\"Le thread a été annulé ; cnt = %d\\en\", cnt);\n"
1187 " else\n"
1188 " printf(\"Thread terminé normalement ; cnt = %d\\en\", cnt);\n"
1189 " exit(EXIT_SUCCESS);\n"
1190 "}\n"
1191
1192 #. type: TH
1193 #: fedora-44 fedora-rawhide
1194 #, no-wrap
1195 msgid "2024-12-13"
1196 msgstr "13 décembre 2024"
1197
1198 #. type: TH
1199 #: fedora-44 fedora-rawhide
1200 #, no-wrap
1201 msgid "Linux man-pages 6.13"
1202 msgstr "Pages du manuel de Linux 6.13"
1203
1204 #. type: TH
1205 #: mageia-cauldron
1206 #, no-wrap
1207 msgid "Linux man-pages 6.17"
1208 msgstr "Pages du manuel de Linux 6.17"
1209
1210 #. type: TH
1211 #: opensuse-leap-16-1 opensuse-tumbleweed
1212 #, no-wrap
1213 msgid "Linux man-pages (unreleased)"
1214 msgstr "Pages du manuel de Linux (non publiées)"