| 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:38+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 "pthread_cleanup_push" |
| 24 |
msgstr "" |
| 25 |
|
| 26 |
#. type: TH |
| 27 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 28 |
#: opensuse-tumbleweed |
| 29 |
#, no-wrap |
| 30 |
msgid "2025-08-20" |
| 31 |
msgstr "" |
| 32 |
|
| 33 |
#. type: TH |
| 34 |
#: archlinux debian-unstable |
| 35 |
#, no-wrap |
| 36 |
msgid "Linux man-pages 6.18" |
| 37 |
msgstr "" |
| 38 |
|
| 39 |
#. type: SH |
| 40 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 41 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 42 |
#, no-wrap |
| 43 |
msgid "NAME" |
| 44 |
msgstr "" |
| 45 |
|
| 46 |
#. type: Plain text |
| 47 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 48 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 49 |
msgid "" |
| 50 |
"pthread_cleanup_push, pthread_cleanup_pop - push and pop thread cancelation " |
| 51 |
"clean-up handlers" |
| 52 |
msgstr "" |
| 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 "LIBRARY" |
| 59 |
msgstr "" |
| 60 |
|
| 61 |
#. type: Plain text |
| 62 |
#: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron |
| 63 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 64 |
msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)" |
| 65 |
msgstr "" |
| 66 |
|
| 67 |
#. type: SH |
| 68 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 69 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 70 |
#, no-wrap |
| 71 |
msgid "SYNOPSIS" |
| 72 |
msgstr "" |
| 73 |
|
| 74 |
#. type: Plain text |
| 75 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 76 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 77 |
#, no-wrap |
| 78 |
msgid "B<#include E<lt>pthread.hE<gt>>\n" |
| 79 |
msgstr "" |
| 80 |
|
| 81 |
#. type: Plain text |
| 82 |
#: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron |
| 83 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 84 |
#, no-wrap |
| 85 |
msgid "" |
| 86 |
"B<void pthread_cleanup_push(typeof(void (void *)) *>I<routine>B<, void *>I<arg>B<);>\n" |
| 87 |
"B<void pthread_cleanup_pop(int >I<execute>B<);>\n" |
| 88 |
msgstr "" |
| 89 |
|
| 90 |
#. type: SH |
| 91 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 92 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 93 |
#, no-wrap |
| 94 |
msgid "DESCRIPTION" |
| 95 |
msgstr "" |
| 96 |
|
| 97 |
#. type: Plain text |
| 98 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 99 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 100 |
msgid "" |
| 101 |
"These functions manipulate the calling thread's stack of thread-cancelation " |
| 102 |
"clean-up handlers. A clean-up handler is a function that is automatically " |
| 103 |
"executed when a thread is canceled (or in various other circumstances " |
| 104 |
"described below); it might, for example, unlock a mutex so that it becomes " |
| 105 |
"available to other threads in the process." |
| 106 |
msgstr "" |
| 107 |
|
| 108 |
#. type: Plain text |
| 109 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 110 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 111 |
msgid "" |
| 112 |
"The B<pthread_cleanup_push>() function pushes I<routine> onto the top of " |
| 113 |
"the stack of clean-up handlers. When I<routine> is later invoked, it will " |
| 114 |
"be given I<arg> as its argument." |
| 115 |
msgstr "" |
| 116 |
|
| 117 |
#. type: Plain text |
| 118 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 119 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 120 |
msgid "" |
| 121 |
"The B<pthread_cleanup_pop>() function removes the routine at the top of the " |
| 122 |
"stack of clean-up handlers, and optionally executes it if I<execute> is " |
| 123 |
"nonzero." |
| 124 |
msgstr "" |
| 125 |
|
| 126 |
#. type: Plain text |
| 127 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 128 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 129 |
msgid "" |
| 130 |
"A cancelation clean-up handler is popped from the stack and executed in the " |
| 131 |
"following circumstances:" |
| 132 |
msgstr "" |
| 133 |
|
| 134 |
#. type: IP |
| 135 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 136 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 137 |
#, no-wrap |
| 138 |
msgid "\\[bu]" |
| 139 |
msgstr "" |
| 140 |
|
| 141 |
#. type: Plain text |
| 142 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 143 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 144 |
msgid "" |
| 145 |
"When a thread is canceled, all of the stacked clean-up handlers are popped " |
| 146 |
"and executed in the reverse of the order in which they were pushed onto the " |
| 147 |
"stack." |
| 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 "" |
| 154 |
"When a thread terminates by calling B<pthread_exit>(3), all clean-up " |
| 155 |
"handlers are executed as described in the preceding point. (Clean-up " |
| 156 |
"handlers are I<not> called if the thread terminates by performing a " |
| 157 |
"I<return> from the thread start function.)" |
| 158 |
msgstr "" |
| 159 |
|
| 160 |
#. type: Plain text |
| 161 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 162 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 163 |
msgid "" |
| 164 |
"When a thread calls B<pthread_cleanup_pop>() with a nonzero I<execute> " |
| 165 |
"argument, the top-most clean-up handler is popped and executed." |
| 166 |
msgstr "" |
| 167 |
|
| 168 |
#. type: Plain text |
| 169 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 170 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 171 |
msgid "" |
| 172 |
"POSIX.1 permits B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() to " |
| 173 |
"be implemented as macros that expand to text containing \\[aq]B<{>\\[aq] and " |
| 174 |
"\\[aq]B<}>\\[aq], respectively. For this reason, the caller must ensure " |
| 175 |
"that calls to these functions are paired within the same function, and at " |
| 176 |
"the same lexical nesting level. (In other words, a clean-up handler is " |
| 177 |
"established only during the execution of a specified section of code.)" |
| 178 |
msgstr "" |
| 179 |
|
| 180 |
#. type: Plain text |
| 181 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 182 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 183 |
msgid "" |
| 184 |
"Calling B<longjmp>(3) (B<siglongjmp>(3)) produces undefined results if any " |
| 185 |
"call has been made to B<pthread_cleanup_push>() or " |
| 186 |
"B<pthread_cleanup_pop>() without the matching call of the pair since the " |
| 187 |
"jump buffer was filled by B<setjmp>(3) (B<sigsetjmp>(3)). Likewise, " |
| 188 |
"calling B<longjmp>(3) (B<siglongjmp>(3)) from inside a clean-up handler " |
| 189 |
"produces undefined results unless the jump buffer was also filled by " |
| 190 |
"B<setjmp>(3) (B<sigsetjmp>(3)) inside the handler." |
| 191 |
msgstr "" |
| 192 |
|
| 193 |
#. type: SH |
| 194 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 195 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 196 |
#, no-wrap |
| 197 |
msgid "RETURN VALUE" |
| 198 |
msgstr "" |
| 199 |
|
| 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 "These functions do not return a value." |
| 204 |
msgstr "" |
| 205 |
|
| 206 |
#. type: SH |
| 207 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 208 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 209 |
#, no-wrap |
| 210 |
msgid "ERRORS" |
| 211 |
msgstr "" |
| 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 "There are no errors." |
| 217 |
msgstr "" |
| 218 |
|
| 219 |
#. type: SH |
| 220 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 221 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 222 |
#, no-wrap |
| 223 |
msgid "ATTRIBUTES" |
| 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 "" |
| 230 |
"For an explanation of the terms used in this section, see B<attributes>(7)." |
| 231 |
msgstr "" |
| 232 |
|
| 233 |
#. type: tbl table |
| 234 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 235 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 236 |
#, no-wrap |
| 237 |
msgid "Interface" |
| 238 |
msgstr "" |
| 239 |
|
| 240 |
#. type: tbl table |
| 241 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 242 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 243 |
#, no-wrap |
| 244 |
msgid "Attribute" |
| 245 |
msgstr "" |
| 246 |
|
| 247 |
#. type: tbl table |
| 248 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 249 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 250 |
#, no-wrap |
| 251 |
msgid "Value" |
| 252 |
msgstr "" |
| 253 |
|
| 254 |
#. type: tbl table |
| 255 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 256 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 257 |
#, no-wrap |
| 258 |
msgid ".na\n" |
| 259 |
msgstr "" |
| 260 |
|
| 261 |
#. type: tbl table |
| 262 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 263 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 264 |
#, no-wrap |
| 265 |
msgid ".nh\n" |
| 266 |
msgstr "" |
| 267 |
|
| 268 |
#. type: tbl table |
| 269 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 270 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 271 |
#, no-wrap |
| 272 |
msgid "" |
| 273 |
"B<pthread_cleanup_push>(),\n" |
| 274 |
"B<pthread_cleanup_pop>()" |
| 275 |
msgstr "" |
| 276 |
|
| 277 |
#. type: tbl table |
| 278 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 279 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 280 |
#, no-wrap |
| 281 |
msgid "Thread safety" |
| 282 |
msgstr "" |
| 283 |
|
| 284 |
#. type: tbl table |
| 285 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 286 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 287 |
#, no-wrap |
| 288 |
msgid "MT-Safe" |
| 289 |
msgstr "" |
| 290 |
|
| 291 |
#. type: SH |
| 292 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 293 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 294 |
#, no-wrap |
| 295 |
msgid "VERSIONS" |
| 296 |
msgstr "" |
| 297 |
|
| 298 |
#. type: Plain text |
| 299 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 300 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 301 |
msgid "" |
| 302 |
"On glibc, the B<pthread_cleanup_push>() and B<pthread_cleanup_pop>() " |
| 303 |
"functions I<are> implemented as macros that expand to text containing \\" |
| 304 |
"[aq]B<{>\\[aq] and \\[aq]B<}>\\[aq], respectively. This means that " |
| 305 |
"variables declared within the scope of paired calls to these functions will " |
| 306 |
"be visible within only that scope." |
| 307 |
msgstr "" |
| 308 |
|
| 309 |
#. The text was actually added in the 2004 TC2 |
| 310 |
#. type: Plain text |
| 311 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 312 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 313 |
msgid "" |
| 314 |
"POSIX.1 says that the effect of using I<return>, I<break>, I<continue>, or " |
| 315 |
"I<goto> to prematurely leave a block bracketed B<pthread_cleanup_push>() " |
| 316 |
"and B<pthread_cleanup_pop>() is undefined. Portable applications should " |
| 317 |
"avoid doing this." |
| 318 |
msgstr "" |
| 319 |
|
| 320 |
#. type: SH |
| 321 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 322 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 323 |
#, no-wrap |
| 324 |
msgid "STANDARDS" |
| 325 |
msgstr "" |
| 326 |
|
| 327 |
#. type: Plain text |
| 328 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 329 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 330 |
msgid "POSIX.1-2008." |
| 331 |
msgstr "" |
| 332 |
|
| 333 |
#. type: SH |
| 334 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 335 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 336 |
#, no-wrap |
| 337 |
msgid "HISTORY" |
| 338 |
msgstr "" |
| 339 |
|
| 340 |
#. type: Plain text |
| 341 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 342 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 343 |
msgid "POSIX.1-2001. glibc 2.0." |
| 344 |
msgstr "" |
| 345 |
|
| 346 |
#. type: SH |
| 347 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 348 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 349 |
#, no-wrap |
| 350 |
msgid "EXAMPLES" |
| 351 |
msgstr "" |
| 352 |
|
| 353 |
#. type: Plain text |
| 354 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 355 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 356 |
msgid "" |
| 357 |
"The program below provides a simple example of the use of the functions " |
| 358 |
"described in this page. The program creates a thread that executes a loop " |
| 359 |
"bracketed by B<pthread_cleanup_push>() and B<pthread_cleanup_pop>(). This " |
| 360 |
"loop increments a global variable, I<cnt>, once each second. Depending on " |
| 361 |
"what command-line arguments are supplied, the main thread sends the other " |
| 362 |
"thread a cancelation request, or sets a global variable that causes the " |
| 363 |
"other thread to exit its loop and terminate normally (by doing a I<return>)." |
| 364 |
msgstr "" |
| 365 |
|
| 366 |
#. type: Plain text |
| 367 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 368 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 369 |
msgid "" |
| 370 |
"In the following shell session, the main thread sends a cancelation request " |
| 371 |
"to the other thread:" |
| 372 |
msgstr "" |
| 373 |
|
| 374 |
#. type: Plain text |
| 375 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 376 |
#: opensuse-tumbleweed |
| 377 |
#, no-wrap |
| 378 |
msgid "" |
| 379 |
"$B< ./a.out>;\n" |
| 380 |
"New thread started\n" |
| 381 |
"cnt = 0\n" |
| 382 |
"cnt = 1\n" |
| 383 |
"Canceling thread\n" |
| 384 |
"Called clean-up handler\n" |
| 385 |
"Thread was canceled; cnt = 0\n" |
| 386 |
msgstr "" |
| 387 |
|
| 388 |
#. type: Plain text |
| 389 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 390 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 391 |
msgid "" |
| 392 |
"From the above, we see that the thread was canceled, and that the " |
| 393 |
"cancelation clean-up handler was called and it reset the value of the global " |
| 394 |
"variable I<cnt> to 0." |
| 395 |
msgstr "" |
| 396 |
|
| 397 |
#. type: Plain text |
| 398 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 399 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 400 |
msgid "" |
| 401 |
"In the next run, the main program sets a global variable that causes other " |
| 402 |
"thread to terminate normally:" |
| 403 |
msgstr "" |
| 404 |
|
| 405 |
#. type: Plain text |
| 406 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 407 |
#: opensuse-tumbleweed |
| 408 |
#, no-wrap |
| 409 |
msgid "" |
| 410 |
"$B< ./a.out x>;\n" |
| 411 |
"New thread started\n" |
| 412 |
"cnt = 0\n" |
| 413 |
"cnt = 1\n" |
| 414 |
"Thread terminated normally; cnt = 2\n" |
| 415 |
msgstr "" |
| 416 |
|
| 417 |
#. type: Plain text |
| 418 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 419 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 420 |
msgid "" |
| 421 |
"From the above, we see that the clean-up handler was not executed (because " |
| 422 |
"I<cleanup_pop_arg> was 0), and therefore the value of I<cnt> was not reset." |
| 423 |
msgstr "" |
| 424 |
|
| 425 |
#. type: Plain text |
| 426 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 427 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 428 |
msgid "" |
| 429 |
"In the next run, the main program sets a global variable that causes the " |
| 430 |
"other thread to terminate normally, and supplies a nonzero value for " |
| 431 |
"I<cleanup_pop_arg>:" |
| 432 |
msgstr "" |
| 433 |
|
| 434 |
#. type: Plain text |
| 435 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 436 |
#: opensuse-tumbleweed |
| 437 |
#, no-wrap |
| 438 |
msgid "" |
| 439 |
"$B< ./a.out x 1>;\n" |
| 440 |
"New thread started\n" |
| 441 |
"cnt = 0\n" |
| 442 |
"cnt = 1\n" |
| 443 |
"Called clean-up handler\n" |
| 444 |
"Thread terminated normally; cnt = 0\n" |
| 445 |
msgstr "" |
| 446 |
|
| 447 |
#. type: Plain text |
| 448 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 449 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 450 |
msgid "" |
| 451 |
"In the above, we see that although the thread was not canceled, the clean-up " |
| 452 |
"handler was executed, because the argument given to " |
| 453 |
"B<pthread_cleanup_pop>() was nonzero." |
| 454 |
msgstr "" |
| 455 |
|
| 456 |
#. type: SS |
| 457 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 458 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 459 |
#, no-wrap |
| 460 |
msgid "Program source" |
| 461 |
msgstr "" |
| 462 |
|
| 463 |
#. type: Plain text |
| 464 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 465 |
#: opensuse-tumbleweed |
| 466 |
#, no-wrap |
| 467 |
msgid "" |
| 468 |
"#include E<lt>err.hE<gt>\n" |
| 469 |
"#include E<lt>errno.hE<gt>\n" |
| 470 |
"#include E<lt>pthread.hE<gt>\n" |
| 471 |
"#include E<lt>stdio.hE<gt>\n" |
| 472 |
"#include E<lt>stdlib.hE<gt>\n" |
| 473 |
"#include E<lt>sys/types.hE<gt>\n" |
| 474 |
"#include E<lt>unistd.hE<gt>\n" |
| 475 |
"\\&\n" |
| 476 |
"static int done = 0;\n" |
| 477 |
"static int cleanup_pop_arg = 0;\n" |
| 478 |
"static int cnt = 0;\n" |
| 479 |
"\\&\n" |
| 480 |
"static void\n" |
| 481 |
"cleanup_handler(void *arg)\n" |
| 482 |
"{\n" |
| 483 |
" printf(\"Called clean-up handler\\[rs]n\");\n" |
| 484 |
" cnt = 0;\n" |
| 485 |
"}\n" |
| 486 |
"\\&\n" |
| 487 |
"static void *\n" |
| 488 |
"thread_start(void *arg)\n" |
| 489 |
"{\n" |
| 490 |
" time_t curr;\n" |
| 491 |
"\\&\n" |
| 492 |
" printf(\"New thread started\\[rs]n\");\n" |
| 493 |
"\\&\n" |
| 494 |
" pthread_cleanup_push(cleanup_handler, NULL);\n" |
| 495 |
"\\&\n" |
| 496 |
" curr = time(NULL);\n" |
| 497 |
"\\&\n" |
| 498 |
" while (!done) {\n" |
| 499 |
" pthread_testcancel(); /* A cancelation point */\n" |
| 500 |
" if (curr E<lt> time(NULL)) {\n" |
| 501 |
" curr = time(NULL);\n" |
| 502 |
" printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n" |
| 503 |
" cnt++;\n" |
| 504 |
" }\n" |
| 505 |
" }\n" |
| 506 |
"\\&\n" |
| 507 |
" pthread_cleanup_pop(cleanup_pop_arg);\n" |
| 508 |
" return NULL;\n" |
| 509 |
"}\n" |
| 510 |
"\\&\n" |
| 511 |
"int\n" |
| 512 |
"main(int argc, char *argv[])\n" |
| 513 |
"{\n" |
| 514 |
" pthread_t thr;\n" |
| 515 |
" int s;\n" |
| 516 |
" void *res;\n" |
| 517 |
"\\&\n" |
| 518 |
" s = pthread_create(&thr, NULL, thread_start, NULL);\n" |
| 519 |
" if (s != 0)\n" |
| 520 |
" errc(EXIT_FAILURE, s, \"pthread_create\");\n" |
| 521 |
"\\&\n" |
| 522 |
" sleep(2); /* Allow new thread to run a while */\n" |
| 523 |
"\\&\n" |
| 524 |
" if (argc E<gt> 1) {\n" |
| 525 |
" if (argc E<gt> 2)\n" |
| 526 |
" cleanup_pop_arg = atoi(argv[2]);\n" |
| 527 |
" done = 1;\n" |
| 528 |
"\\&\n" |
| 529 |
" } else {\n" |
| 530 |
" printf(\"Canceling thread\\[rs]n\");\n" |
| 531 |
" s = pthread_cancel(thr);\n" |
| 532 |
" if (s != 0)\n" |
| 533 |
" errc(EXIT_FAILURE, s, \"pthread_cancel\");\n" |
| 534 |
" }\n" |
| 535 |
"\\&\n" |
| 536 |
" s = pthread_join(thr, &res);\n" |
| 537 |
" if (s != 0)\n" |
| 538 |
" errc(EXIT_FAILURE, s, \"pthread_join\");\n" |
| 539 |
"\\&\n" |
| 540 |
" if (res == PTHREAD_CANCELED)\n" |
| 541 |
" printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n" |
| 542 |
" else\n" |
| 543 |
" printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n" |
| 544 |
" exit(EXIT_SUCCESS);\n" |
| 545 |
"}\n" |
| 546 |
msgstr "" |
| 547 |
|
| 548 |
#. SRC END |
| 549 |
#. type: SH |
| 550 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 551 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 552 |
#, no-wrap |
| 553 |
msgid "SEE ALSO" |
| 554 |
msgstr "" |
| 555 |
|
| 556 |
#. type: Plain text |
| 557 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 558 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 559 |
msgid "" |
| 560 |
"B<pthread_cancel>(3), B<pthread_cleanup_push_defer_np>(3), " |
| 561 |
"B<pthread_setcancelstate>(3), B<pthread_testcancel>(3), B<pthreads>(7)" |
| 562 |
msgstr "" |
| 563 |
|
| 564 |
#. type: TH |
| 565 |
#: debian-trixie |
| 566 |
#, no-wrap |
| 567 |
msgid "2024-06-15" |
| 568 |
msgstr "" |
| 569 |
|
| 570 |
#. type: TH |
| 571 |
#: debian-trixie |
| 572 |
#, no-wrap |
| 573 |
msgid "Linux man-pages 6.9.1" |
| 574 |
msgstr "" |
| 575 |
|
| 576 |
#. type: Plain text |
| 577 |
#: debian-trixie |
| 578 |
msgid "POSIX threads library (I<libpthread>, I<-lpthread>)" |
| 579 |
msgstr "" |
| 580 |
|
| 581 |
#. type: Plain text |
| 582 |
#: debian-trixie |
| 583 |
#, no-wrap |
| 584 |
msgid "" |
| 585 |
"B<void pthread_cleanup_push(void (*>I<routine>B<)(void *), void *>I<arg>B<);>\n" |
| 586 |
"B<void pthread_cleanup_pop(int >I<execute>B<);>\n" |
| 587 |
msgstr "" |
| 588 |
|
| 589 |
#. type: Plain text |
| 590 |
#: debian-trixie fedora-44 fedora-rawhide |
| 591 |
#, no-wrap |
| 592 |
msgid "" |
| 593 |
"$ B<./a.out>\n" |
| 594 |
"New thread started\n" |
| 595 |
"cnt = 0\n" |
| 596 |
"cnt = 1\n" |
| 597 |
"Canceling thread\n" |
| 598 |
"Called clean-up handler\n" |
| 599 |
"Thread was canceled; cnt = 0\n" |
| 600 |
msgstr "" |
| 601 |
|
| 602 |
#. type: Plain text |
| 603 |
#: debian-trixie fedora-44 fedora-rawhide |
| 604 |
#, no-wrap |
| 605 |
msgid "" |
| 606 |
"$ B<./a.out x>\n" |
| 607 |
"New thread started\n" |
| 608 |
"cnt = 0\n" |
| 609 |
"cnt = 1\n" |
| 610 |
"Thread terminated normally; cnt = 2\n" |
| 611 |
msgstr "" |
| 612 |
|
| 613 |
#. type: Plain text |
| 614 |
#: debian-trixie fedora-44 fedora-rawhide |
| 615 |
#, no-wrap |
| 616 |
msgid "" |
| 617 |
"$ B<./a.out x 1>\n" |
| 618 |
"New thread started\n" |
| 619 |
"cnt = 0\n" |
| 620 |
"cnt = 1\n" |
| 621 |
"Called clean-up handler\n" |
| 622 |
"Thread terminated normally; cnt = 0\n" |
| 623 |
msgstr "" |
| 624 |
|
| 625 |
#. type: Plain text |
| 626 |
#: debian-trixie fedora-44 fedora-rawhide |
| 627 |
#, no-wrap |
| 628 |
msgid "" |
| 629 |
"#include E<lt>errno.hE<gt>\n" |
| 630 |
"#include E<lt>pthread.hE<gt>\n" |
| 631 |
"#include E<lt>stdio.hE<gt>\n" |
| 632 |
"#include E<lt>stdlib.hE<gt>\n" |
| 633 |
"#include E<lt>sys/types.hE<gt>\n" |
| 634 |
"#include E<lt>unistd.hE<gt>\n" |
| 635 |
"\\&\n" |
| 636 |
"#define handle_error_en(en, msg) \\[rs]\n" |
| 637 |
" do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n" |
| 638 |
"\\&\n" |
| 639 |
"static int done = 0;\n" |
| 640 |
"static int cleanup_pop_arg = 0;\n" |
| 641 |
"static int cnt = 0;\n" |
| 642 |
"\\&\n" |
| 643 |
"static void\n" |
| 644 |
"cleanup_handler(void *arg)\n" |
| 645 |
"{\n" |
| 646 |
" printf(\"Called clean-up handler\\[rs]n\");\n" |
| 647 |
" cnt = 0;\n" |
| 648 |
"}\n" |
| 649 |
"\\&\n" |
| 650 |
"static void *\n" |
| 651 |
"thread_start(void *arg)\n" |
| 652 |
"{\n" |
| 653 |
" time_t curr;\n" |
| 654 |
"\\&\n" |
| 655 |
" printf(\"New thread started\\[rs]n\");\n" |
| 656 |
"\\&\n" |
| 657 |
" pthread_cleanup_push(cleanup_handler, NULL);\n" |
| 658 |
"\\&\n" |
| 659 |
" curr = time(NULL);\n" |
| 660 |
"\\&\n" |
| 661 |
" while (!done) {\n" |
| 662 |
" pthread_testcancel(); /* A cancelation point */\n" |
| 663 |
" if (curr E<lt> time(NULL)) {\n" |
| 664 |
" curr = time(NULL);\n" |
| 665 |
" printf(\"cnt = %d\\[rs]n\", cnt); /* A cancelation point */\n" |
| 666 |
" cnt++;\n" |
| 667 |
" }\n" |
| 668 |
" }\n" |
| 669 |
"\\&\n" |
| 670 |
" pthread_cleanup_pop(cleanup_pop_arg);\n" |
| 671 |
" return NULL;\n" |
| 672 |
"}\n" |
| 673 |
"\\&\n" |
| 674 |
"int\n" |
| 675 |
"main(int argc, char *argv[])\n" |
| 676 |
"{\n" |
| 677 |
" pthread_t thr;\n" |
| 678 |
" int s;\n" |
| 679 |
" void *res;\n" |
| 680 |
"\\&\n" |
| 681 |
" s = pthread_create(&thr, NULL, thread_start, NULL);\n" |
| 682 |
" if (s != 0)\n" |
| 683 |
" handle_error_en(s, \"pthread_create\");\n" |
| 684 |
"\\&\n" |
| 685 |
" sleep(2); /* Allow new thread to run a while */\n" |
| 686 |
"\\&\n" |
| 687 |
" if (argc E<gt> 1) {\n" |
| 688 |
" if (argc E<gt> 2)\n" |
| 689 |
" cleanup_pop_arg = atoi(argv[2]);\n" |
| 690 |
" done = 1;\n" |
| 691 |
"\\&\n" |
| 692 |
" } else {\n" |
| 693 |
" printf(\"Canceling thread\\[rs]n\");\n" |
| 694 |
" s = pthread_cancel(thr);\n" |
| 695 |
" if (s != 0)\n" |
| 696 |
" handle_error_en(s, \"pthread_cancel\");\n" |
| 697 |
" }\n" |
| 698 |
"\\&\n" |
| 699 |
" s = pthread_join(thr, &res);\n" |
| 700 |
" if (s != 0)\n" |
| 701 |
" handle_error_en(s, \"pthread_join\");\n" |
| 702 |
"\\&\n" |
| 703 |
" if (res == PTHREAD_CANCELED)\n" |
| 704 |
" printf(\"Thread was canceled; cnt = %d\\[rs]n\", cnt);\n" |
| 705 |
" else\n" |
| 706 |
" printf(\"Thread terminated normally; cnt = %d\\[rs]n\", cnt);\n" |
| 707 |
" exit(EXIT_SUCCESS);\n" |
| 708 |
"}\n" |
| 709 |
msgstr "" |
| 710 |
|
| 711 |
#. type: TH |
| 712 |
#: fedora-44 fedora-rawhide |
| 713 |
#, no-wrap |
| 714 |
msgid "2024-12-13" |
| 715 |
msgstr "" |
| 716 |
|
| 717 |
#. type: TH |
| 718 |
#: fedora-44 fedora-rawhide |
| 719 |
#, no-wrap |
| 720 |
msgid "Linux man-pages 6.13" |
| 721 |
msgstr "" |
| 722 |
|
| 723 |
#. type: TH |
| 724 |
#: mageia-cauldron |
| 725 |
#, no-wrap |
| 726 |
msgid "Linux man-pages 6.17" |
| 727 |
msgstr "" |
| 728 |
|
| 729 |
#. type: TH |
| 730 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 731 |
#, no-wrap |
| 732 |
msgid "Linux man-pages (unreleased)" |
| 733 |
msgstr "" |