Debian Codegraph @

templates/man3/pthread_create.3.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06: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_create"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-10"
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 "pthread_create - create a new thread"
50 msgstr ""
51
52 #. type: SH
53 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
54 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
55 #, no-wrap
56 msgid "LIBRARY"
57 msgstr ""
58
59 #. type: Plain text
60 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
61 #: opensuse-leap-16-1 opensuse-tumbleweed
62 msgid "POSIX threads library (I<libpthread>,\\ I<-lpthread>)"
63 msgstr ""
64
65 #. type: SH
66 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
67 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
68 #, no-wrap
69 msgid "SYNOPSIS"
70 msgstr ""
71
72 #. type: Plain text
73 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
74 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
75 #, no-wrap
76 msgid "B<#include E<lt>pthread.hE<gt>>\n"
77 msgstr ""
78
79 #. type: Plain text
80 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
81 #: opensuse-tumbleweed
82 #, no-wrap
83 msgid ""
84 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
85 "B< const pthread_attr_t *_Nullable restrict >I<attr>B<,>\n"
86 "B< typeof(void *(void *_Nullable)) *>I<start_routine>B<,>\n"
87 "B< void *_Nullable restrict >I<arg>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 "The B<pthread_create>() function starts a new thread in the calling "
102 "process. The new thread starts execution by invoking I<start_routine>(); "
103 "I<arg> is passed as the sole argument of I<start_routine>()."
104 msgstr ""
105
106 #. type: Plain text
107 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
108 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
109 msgid "The new thread terminates in one of the following ways:"
110 msgstr ""
111
112 #. type: IP
113 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
114 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
115 #, no-wrap
116 msgid "\\[bu]"
117 msgstr ""
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 "It calls B<pthread_exit>(3), specifying an exit status value that is "
124 "available to another thread in the same process that calls "
125 "B<pthread_join>(3)."
126 msgstr ""
127
128 #. type: Plain text
129 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
130 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
131 msgid ""
132 "It returns from I<start_routine>(). This is equivalent to calling "
133 "B<pthread_exit>(3) with the value supplied in the I<return> statement."
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 "It is canceled (see B<pthread_cancel>(3))."
140 msgstr ""
141
142 #. type: Plain text
143 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
144 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
145 msgid ""
146 "Any of the threads in the process calls B<exit>(3), or the main thread "
147 "performs a return from I<main>(). This causes the termination of all "
148 "threads in the process."
149 msgstr ""
150
151 #. type: Plain text
152 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
153 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
154 msgid ""
155 "The I<attr> argument points to a I<pthread_attr_t> structure whose contents "
156 "are used at thread creation time to determine attributes for the new thread; "
157 "this structure is initialized using B<pthread_attr_init>(3) and related "
158 "functions. If I<attr> is NULL, then the thread is created with default "
159 "attributes."
160 msgstr ""
161
162 #. type: Plain text
163 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
164 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
165 msgid ""
166 "Before returning, a successful call to B<pthread_create>() stores the ID of "
167 "the new thread in the buffer pointed to by I<thread>; this identifier is "
168 "used to refer to the thread in subsequent calls to other pthreads functions."
169 msgstr ""
170
171 #. type: Plain text
172 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
173 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
174 msgid ""
175 "The new thread inherits a copy of the creating thread's signal mask "
176 "(B<pthread_sigmask>(3)). The set of pending signals for the new thread is "
177 "empty (B<sigpending>(2)). The new thread does not inherit the creating "
178 "thread's alternate signal stack (B<sigaltstack>(2))."
179 msgstr ""
180
181 #. type: Plain text
182 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
183 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
184 msgid ""
185 "The new thread inherits the calling thread's floating-point environment "
186 "(B<fenv>(3))."
187 msgstr ""
188
189 #. CLOCK_THREAD_CPUTIME_ID in clock_gettime(2)
190 #. type: Plain text
191 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
192 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
193 msgid ""
194 "The initial value of the new thread's CPU-time clock is 0 (see "
195 "B<pthread_getcpuclockid>(3))."
196 msgstr ""
197
198 #. type: SS
199 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
200 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
201 #, no-wrap
202 msgid "Linux-specific details"
203 msgstr ""
204
205 #. type: Plain text
206 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
207 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
208 msgid ""
209 "The new thread inherits copies of the calling thread's capability sets (see "
210 "B<capabilities>(7)) and CPU affinity mask (see B<sched_setaffinity>(2))."
211 msgstr ""
212
213 #. type: SH
214 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
215 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
216 #, no-wrap
217 msgid "RETURN VALUE"
218 msgstr ""
219
220 #. type: Plain text
221 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
222 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
223 msgid ""
224 "On success, B<pthread_create>() returns 0; on error, it returns an error "
225 "number, and the contents of I<*thread> are undefined."
226 msgstr ""
227
228 #. type: SH
229 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
230 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
231 #, no-wrap
232 msgid "ERRORS"
233 msgstr ""
234
235 #. type: TP
236 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
237 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
238 #, no-wrap
239 msgid "B<EAGAIN>"
240 msgstr ""
241
242 #. type: Plain text
243 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
244 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
245 msgid "Insufficient resources to create another thread."
246 msgstr ""
247
248 #. NOTE! The following should match the description in fork(2)
249 #. type: Plain text
250 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
251 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
252 msgid ""
253 "A system-imposed limit on the number of threads was encountered. There are "
254 "a number of limits that may trigger this error: the B<RLIMIT_NPROC> soft "
255 "resource limit (set via B<setrlimit>(2)), which limits the number of "
256 "processes and threads for a real user ID, was reached; the kernel's system-"
257 "wide limit on the number of processes and threads, I</proc/sys/kernel/"
258 "threads-max>, was reached (see B<proc>(5)); or the maximum number of PIDs, "
259 "I</proc/sys/kernel/pid_max>, was reached (see B<proc>(5))."
260 msgstr ""
261
262 #. type: TP
263 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
264 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
265 #, no-wrap
266 msgid "B<EINVAL>"
267 msgstr ""
268
269 #. type: Plain text
270 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
271 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
272 msgid "Invalid settings in I<attr>."
273 msgstr ""
274
275 #. FIXME . Test the following
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<EPERM>"
281 msgstr ""
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 ""
287 "No permission to set the scheduling policy and parameters specified in "
288 "I<attr>."
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 "ATTRIBUTES"
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 "For an explanation of the terms used in this section, see B<attributes>(7)."
303 msgstr ""
304
305 #. type: tbl table
306 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
307 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
308 #, no-wrap
309 msgid "Interface"
310 msgstr ""
311
312 #. type: tbl table
313 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
314 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
315 #, no-wrap
316 msgid "Attribute"
317 msgstr ""
318
319 #. type: tbl table
320 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
321 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
322 #, no-wrap
323 msgid "Value"
324 msgstr ""
325
326 #. type: tbl table
327 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
328 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
329 #, no-wrap
330 msgid ".na\n"
331 msgstr ""
332
333 #. type: tbl table
334 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
335 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
336 #, no-wrap
337 msgid ".nh\n"
338 msgstr ""
339
340 #. type: tbl table
341 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
342 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
343 #, no-wrap
344 msgid "B<pthread_create>()"
345 msgstr ""
346
347 #. type: tbl table
348 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
349 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
350 #, no-wrap
351 msgid "Thread safety"
352 msgstr ""
353
354 #. type: tbl table
355 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
356 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
357 #, no-wrap
358 msgid "MT-Safe"
359 msgstr ""
360
361 #. type: SH
362 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
363 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
364 #, no-wrap
365 msgid "STANDARDS"
366 msgstr ""
367
368 #. type: Plain text
369 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
370 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
371 msgid "POSIX.1-2008."
372 msgstr ""
373
374 #. type: SH
375 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
376 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
377 #, no-wrap
378 msgid "HISTORY"
379 msgstr ""
380
381 #. type: Plain text
382 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
383 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
384 msgid "POSIX.1-2001."
385 msgstr ""
386
387 #. type: SH
388 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
389 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
390 #, no-wrap
391 msgid "NOTES"
392 msgstr ""
393
394 #. type: Plain text
395 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
396 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
397 msgid ""
398 "See B<pthread_self>(3) for further information on the thread ID returned in "
399 "I<*thread> by B<pthread_create>(). Unless real-time scheduling policies are "
400 "being employed, after a call to B<pthread_create>(), it is indeterminate "
401 "which thread\\[em]the caller or the new thread\\[em]will next execute."
402 msgstr ""
403
404 #. type: Plain text
405 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
406 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
407 msgid ""
408 "A thread may either be I<joinable> or I<detached>. If a thread is joinable, "
409 "then another thread can call B<pthread_join>(3) to wait for the thread to "
410 "terminate and fetch its exit status. Only when a terminated joinable thread "
411 "has been joined are the last of its resources released back to the system. "
412 "When a detached thread terminates, its resources are automatically released "
413 "back to the system: it is not possible to join with the thread in order to "
414 "obtain its exit status. Making a thread detached is useful for some types "
415 "of daemon threads whose exit status the application does not need to care "
416 "about. By default, a new thread is created in a joinable state, unless "
417 "I<attr> was set to create the thread in a detached state (using "
418 "B<pthread_attr_setdetachstate>(3))."
419 msgstr ""
420
421 #. type: Plain text
422 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
423 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
424 msgid ""
425 "Under the NPTL threading implementation, if the B<RLIMIT_STACK> soft "
426 "resource limit I<at the time the program started> has any value other than "
427 "\"unlimited\", then it determines the default stack size of new threads. "
428 "Using B<pthread_attr_setstacksize>(3), the stack size attribute can be "
429 "explicitly set in the I<attr> argument used to create a thread, in order to "
430 "obtain a stack size other than the default. If the B<RLIMIT_STACK> resource "
431 "limit is set to \"unlimited\", a per-architecture value is used for the "
432 "stack size: 2 MB on most architectures; 4 MB on POWER and Sparc-64."
433 msgstr ""
434
435 #. type: SH
436 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
437 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
438 #, no-wrap
439 msgid "BUGS"
440 msgstr ""
441
442 #. type: Plain text
443 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
444 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
445 msgid ""
446 "In the obsolete LinuxThreads implementation, each of the threads in a "
447 "process has a different process ID. This is in violation of the POSIX "
448 "threads specification, and is the source of many other nonconformances to "
449 "the standard; see B<pthreads>(7)."
450 msgstr ""
451
452 #. type: SH
453 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
454 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
455 #, no-wrap
456 msgid "EXAMPLES"
457 msgstr ""
458
459 #. type: Plain text
460 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
461 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
462 msgid ""
463 "The program below demonstrates the use of B<pthread_create>(), as well as a "
464 "number of other functions in the pthreads API."
465 msgstr ""
466
467 #. type: Plain text
468 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
469 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
470 msgid ""
471 "In the following run, on a system providing the NPTL threading "
472 "implementation, the stack size defaults to the value given by the \"stack "
473 "size\" resource limit:"
474 msgstr ""
475
476 #. type: Plain text
477 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
478 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
479 #, no-wrap
480 msgid ""
481 "$B< ulimit -s>\n"
482 "8192 # The stack size limit is 8 MB (0x800000 bytes)\n"
483 "$B< ./a.out hola salut servus>\n"
484 "Thread 1: top of stack near 0xb7dd03b8; argv_string=hola\n"
485 "Thread 2: top of stack near 0xb75cf3b8; argv_string=salut\n"
486 "Thread 3: top of stack near 0xb6dce3b8; argv_string=servus\n"
487 "Joined with thread 1; returned value was HOLA\n"
488 "Joined with thread 2; returned value was SALUT\n"
489 "Joined with thread 3; returned value was SERVUS\n"
490 msgstr ""
491
492 #. type: Plain text
493 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
494 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
495 msgid ""
496 "In the next run, the program explicitly sets a stack size of 1\\ MB (using "
497 "B<pthread_attr_setstacksize>(3)) for the created threads:"
498 msgstr ""
499
500 #. type: Plain text
501 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
502 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
503 #, no-wrap
504 msgid ""
505 "$B< ./a.out -s 0x100000 hola salut servus>\n"
506 "Thread 1: top of stack near 0xb7d723b8; argv_string=hola\n"
507 "Thread 2: top of stack near 0xb7c713b8; argv_string=salut\n"
508 "Thread 3: top of stack near 0xb7b703b8; argv_string=servus\n"
509 "Joined with thread 1; returned value was HOLA\n"
510 "Joined with thread 2; returned value was SALUT\n"
511 "Joined with thread 3; returned value was SERVUS\n"
512 msgstr ""
513
514 #. type: SS
515 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
516 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
517 #, no-wrap
518 msgid "Program source"
519 msgstr ""
520
521 #. type: Plain text
522 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
523 #: opensuse-tumbleweed
524 #, no-wrap
525 msgid ""
526 "#include E<lt>ctype.hE<gt>\n"
527 "#include E<lt>err.hE<gt>\n"
528 "#include E<lt>pthread.hE<gt>\n"
529 "#include E<lt>stdio.hE<gt>\n"
530 "#include E<lt>stdlib.hE<gt>\n"
531 "#include E<lt>string.hE<gt>\n"
532 "#include E<lt>sys/types.hE<gt>\n"
533 "#include E<lt>unistd.hE<gt>\n"
534 "\\&\n"
535 "struct thread_info { /* Used as argument to thread_start() */\n"
536 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
537 " int thread_num; /* Application-defined thread # */\n"
538 " char *argv_string; /* From command-line argument */\n"
539 "};\n"
540 "\\&\n"
541 "/* Thread start function: display address near top of our stack,\n"
542 " and return upper-cased copy of argv_string. */\n"
543 "\\&\n"
544 "static void *\n"
545 "thread_start(void *arg)\n"
546 "{\n"
547 " struct thread_info *tinfo = arg;\n"
548 " char *uargv;\n"
549 "\\&\n"
550 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\[rs]n\",\n"
551 " tinfo-E<gt>thread_num, (void *) &tinfo, tinfo-E<gt>argv_string);\n"
552 "\\&\n"
553 " uargv = strdup(tinfo-E<gt>argv_string);\n"
554 " if (uargv == NULL)\n"
555 " err(EXIT_FAILURE, \"strdup\");\n"
556 "\\&\n"
557 " for (char *p = uargv; *p != \\[aq]\\[rs]0\\[aq]; p++)\n"
558 " *p = toupper(*p);\n"
559 "\\&\n"
560 " return uargv;\n"
561 "}\n"
562 "\\&\n"
563 "int\n"
564 "main(int argc, char *argv[])\n"
565 "{\n"
566 " int s, opt;\n"
567 " void *res;\n"
568 " size_t num_threads;\n"
569 " ssize_t stack_size;\n"
570 " pthread_attr_t attr;\n"
571 " struct thread_info *tinfo;\n"
572 "\\&\n"
573 " /* The \"-s\" option specifies a stack size for our threads. */\n"
574 "\\&\n"
575 " stack_size = -1;\n"
576 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
577 " switch (opt) {\n"
578 " case \\[aq]s\\[aq]:\n"
579 " stack_size = strtoul(optarg, NULL, 0);\n"
580 " break;\n"
581 "\\&\n"
582 " default:\n"
583 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\[rs]n\",\n"
584 " argv[0]);\n"
585 " exit(EXIT_FAILURE);\n"
586 " }\n"
587 " }\n"
588 "\\&\n"
589 " num_threads = argc - optind;\n"
590 "\\&\n"
591 " /* Initialize thread creation attributes. */\n"
592 "\\&\n"
593 " s = pthread_attr_init(&attr);\n"
594 " if (s != 0)\n"
595 " errc(EXIT_FAILURE, s, \"pthread_attr_init\");\n"
596 "\\&\n"
597 " if (stack_size E<gt> 0) {\n"
598 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
599 " if (s != 0)\n"
600 " errc(EXIT_FAILURE, s, \"pthread_attr_setstacksize\");\n"
601 " }\n"
602 "\\&\n"
603 " /* Allocate memory for pthread_create() arguments. */\n"
604 "\\&\n"
605 " tinfo = calloc(num_threads, sizeof(*tinfo));\n"
606 " if (tinfo == NULL)\n"
607 " err(EXIT_FAILURE, \"calloc\");\n"
608 "\\&\n"
609 " /* Create one thread for each command-line argument. */\n"
610 "\\&\n"
611 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
612 " tinfo[tnum].thread_num = tnum + 1;\n"
613 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
614 "\\&\n"
615 " /* The pthread_create() call stores the thread ID into\n"
616 " corresponding element of tinfo[]. */\n"
617 "\\&\n"
618 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
619 " &thread_start, &tinfo[tnum]);\n"
620 " if (s != 0)\n"
621 " errc(EXIT_FAILURE, s, \"pthread_create\");\n"
622 " }\n"
623 "\\&\n"
624 " /* Destroy the thread attributes object, since it is no\n"
625 " longer needed. */\n"
626 "\\&\n"
627 " s = pthread_attr_destroy(&attr);\n"
628 " if (s != 0)\n"
629 " errc(EXIT_FAILURE, s, \"pthread_attr_destroy\");\n"
630 "\\&\n"
631 " /* Now join with each thread, and display its returned value. */\n"
632 "\\&\n"
633 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
634 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
635 " if (s != 0)\n"
636 " errc(EXIT_FAILURE, s, \"pthread_join\");\n"
637 "\\&\n"
638 " printf(\"Joined with thread %d; returned value was %s\\[rs]n\",\n"
639 " tinfo[tnum].thread_num, (char *) res);\n"
640 " free(res); /* Free memory allocated by thread */\n"
641 " }\n"
642 "\\&\n"
643 " free(tinfo);\n"
644 " exit(EXIT_SUCCESS);\n"
645 "}\n"
646 msgstr ""
647
648 #. SRC END
649 #. type: SH
650 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
651 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
652 #, no-wrap
653 msgid "SEE ALSO"
654 msgstr ""
655
656 #. type: Plain text
657 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
658 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
659 msgid ""
660 "B<getrlimit>(2), B<pthread_attr_init>(3), B<pthread_cancel>(3), "
661 "B<pthread_detach>(3), B<pthread_equal>(3), B<pthread_exit>(3), "
662 "B<pthread_getattr_np>(3), B<pthread_join>(3), B<pthread_self>(3), "
663 "B<pthread_setattr_default_np>(3), B<pthreads>(7)"
664 msgstr ""
665
666 #. type: TH
667 #: debian-trixie
668 #, no-wrap
669 msgid "2024-06-15"
670 msgstr ""
671
672 #. type: TH
673 #: debian-trixie
674 #, no-wrap
675 msgid "Linux man-pages 6.9.1"
676 msgstr ""
677
678 #. type: Plain text
679 #: debian-trixie
680 msgid "POSIX threads library (I<libpthread>, I<-lpthread>)"
681 msgstr ""
682
683 #. type: Plain text
684 #: debian-trixie
685 #, no-wrap
686 msgid ""
687 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
688 "B< const pthread_attr_t *restrict >I<attr>B<,>\n"
689 "B< void *(*>I<start_routine>B<)(void *),>\n"
690 "B< void *restrict >I<arg>B<);>\n"
691 msgstr ""
692
693 #. type: Plain text
694 #: debian-trixie fedora-44 fedora-rawhide
695 #, no-wrap
696 msgid ""
697 "#include E<lt>ctype.hE<gt>\n"
698 "#include E<lt>errno.hE<gt>\n"
699 "#include E<lt>pthread.hE<gt>\n"
700 "#include E<lt>stdio.hE<gt>\n"
701 "#include E<lt>stdlib.hE<gt>\n"
702 "#include E<lt>string.hE<gt>\n"
703 "#include E<lt>sys/types.hE<gt>\n"
704 "#include E<lt>unistd.hE<gt>\n"
705 "\\&\n"
706 "#define handle_error_en(en, msg) \\[rs]\n"
707 " do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)\n"
708 "\\&\n"
709 "#define handle_error(msg) \\[rs]\n"
710 " do { perror(msg); exit(EXIT_FAILURE); } while (0)\n"
711 "\\&\n"
712 "struct thread_info { /* Used as argument to thread_start() */\n"
713 " pthread_t thread_id; /* ID returned by pthread_create() */\n"
714 " int thread_num; /* Application-defined thread # */\n"
715 " char *argv_string; /* From command-line argument */\n"
716 "};\n"
717 "\\&\n"
718 "/* Thread start function: display address near top of our stack,\n"
719 " and return upper-cased copy of argv_string. */\n"
720 "\\&\n"
721 "static void *\n"
722 "thread_start(void *arg)\n"
723 "{\n"
724 " struct thread_info *tinfo = arg;\n"
725 " char *uargv;\n"
726 "\\&\n"
727 " printf(\"Thread %d: top of stack near %p; argv_string=%s\\[rs]n\",\n"
728 " tinfo-E<gt>thread_num, (void *) &tinfo, tinfo-E<gt>argv_string);\n"
729 "\\&\n"
730 " uargv = strdup(tinfo-E<gt>argv_string);\n"
731 " if (uargv == NULL)\n"
732 " handle_error(\"strdup\");\n"
733 "\\&\n"
734 " for (char *p = uargv; *p != \\[aq]\\[rs]0\\[aq]; p++)\n"
735 " *p = toupper(*p);\n"
736 "\\&\n"
737 " return uargv;\n"
738 "}\n"
739 "\\&\n"
740 "int\n"
741 "main(int argc, char *argv[])\n"
742 "{\n"
743 " int s, opt;\n"
744 " void *res;\n"
745 " size_t num_threads;\n"
746 " ssize_t stack_size;\n"
747 " pthread_attr_t attr;\n"
748 " struct thread_info *tinfo;\n"
749 "\\&\n"
750 " /* The \"-s\" option specifies a stack size for our threads. */\n"
751 "\\&\n"
752 " stack_size = -1;\n"
753 " while ((opt = getopt(argc, argv, \"s:\")) != -1) {\n"
754 " switch (opt) {\n"
755 " case \\[aq]s\\[aq]:\n"
756 " stack_size = strtoul(optarg, NULL, 0);\n"
757 " break;\n"
758 "\\&\n"
759 " default:\n"
760 " fprintf(stderr, \"Usage: %s [-s stack-size] arg...\\[rs]n\",\n"
761 " argv[0]);\n"
762 " exit(EXIT_FAILURE);\n"
763 " }\n"
764 " }\n"
765 "\\&\n"
766 " num_threads = argc - optind;\n"
767 "\\&\n"
768 " /* Initialize thread creation attributes. */\n"
769 "\\&\n"
770 " s = pthread_attr_init(&attr);\n"
771 " if (s != 0)\n"
772 " handle_error_en(s, \"pthread_attr_init\");\n"
773 "\\&\n"
774 " if (stack_size E<gt> 0) {\n"
775 " s = pthread_attr_setstacksize(&attr, stack_size);\n"
776 " if (s != 0)\n"
777 " handle_error_en(s, \"pthread_attr_setstacksize\");\n"
778 " }\n"
779 "\\&\n"
780 " /* Allocate memory for pthread_create() arguments. */\n"
781 "\\&\n"
782 " tinfo = calloc(num_threads, sizeof(*tinfo));\n"
783 " if (tinfo == NULL)\n"
784 " handle_error(\"calloc\");\n"
785 "\\&\n"
786 " /* Create one thread for each command-line argument. */\n"
787 "\\&\n"
788 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
789 " tinfo[tnum].thread_num = tnum + 1;\n"
790 " tinfo[tnum].argv_string = argv[optind + tnum];\n"
791 "\\&\n"
792 " /* The pthread_create() call stores the thread ID into\n"
793 " corresponding element of tinfo[]. */\n"
794 "\\&\n"
795 " s = pthread_create(&tinfo[tnum].thread_id, &attr,\n"
796 " &thread_start, &tinfo[tnum]);\n"
797 " if (s != 0)\n"
798 " handle_error_en(s, \"pthread_create\");\n"
799 " }\n"
800 "\\&\n"
801 " /* Destroy the thread attributes object, since it is no\n"
802 " longer needed. */\n"
803 "\\&\n"
804 " s = pthread_attr_destroy(&attr);\n"
805 " if (s != 0)\n"
806 " handle_error_en(s, \"pthread_attr_destroy\");\n"
807 "\\&\n"
808 " /* Now join with each thread, and display its returned value. */\n"
809 "\\&\n"
810 " for (size_t tnum = 0; tnum E<lt> num_threads; tnum++) {\n"
811 " s = pthread_join(tinfo[tnum].thread_id, &res);\n"
812 " if (s != 0)\n"
813 " handle_error_en(s, \"pthread_join\");\n"
814 "\\&\n"
815 " printf(\"Joined with thread %d; returned value was %s\\[rs]n\",\n"
816 " tinfo[tnum].thread_num, (char *) res);\n"
817 " free(res); /* Free memory allocated by thread */\n"
818 " }\n"
819 "\\&\n"
820 " free(tinfo);\n"
821 " exit(EXIT_SUCCESS);\n"
822 "}\n"
823 msgstr ""
824
825 #. type: TH
826 #: fedora-44 fedora-rawhide
827 #, no-wrap
828 msgid "2024-12-13"
829 msgstr ""
830
831 #. type: TH
832 #: fedora-44 fedora-rawhide
833 #, no-wrap
834 msgid "Linux man-pages 6.13"
835 msgstr ""
836
837 #. type: Plain text
838 #: fedora-44 fedora-rawhide
839 #, no-wrap
840 msgid ""
841 "B<int pthread_create(pthread_t *restrict >I<thread>B<,>\n"
842 "B< const pthread_attr_t *restrict >I<attr>B<,>\n"
843 "B< typeof(void *(void *)) *>I<start_routine>B<,>\n"
844 "B< void *restrict >I<arg>B<);>\n"
845 msgstr ""
846
847 #. type: TH
848 #: mageia-cauldron
849 #, no-wrap
850 msgid "Linux man-pages 6.17"
851 msgstr ""
852
853 #. type: TH
854 #: opensuse-leap-16-1 opensuse-tumbleweed
855 #, no-wrap
856 msgid "Linux man-pages (unreleased)"
857 msgstr ""