Debian Codegraph @

templates/man3/posix_spawn.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:35+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 "posix_spawn"
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-08"
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 "posix_spawn, posix_spawnp - spawn a process"
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 "Standard C library (I<libc>,\\ I<-lc>)"
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>spawn.hE<gt>>\n"
77 msgstr ""
78
79 #. type: Plain text
80 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
81 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
82 #, no-wrap
83 msgid ""
84 "B<int posix_spawn(pid_t *restrict >I<pid>B<, const char *restrict >I<path>B<,>\n"
85 "B< const posix_spawn_file_actions_t *restrict >I<file_actions>B<,>\n"
86 "B< const posix_spawnattr_t *restrict >I<attrp>B<,>\n"
87 "B< char *const >I<argv>B<[restrict],>\n"
88 "B< char *const >I<envp>B<[restrict]);>\n"
89 "B<int posix_spawnp(pid_t *restrict >I<pid>B<, const char *restrict >I<file>B<,>\n"
90 "B< const posix_spawn_file_actions_t *restrict >I<file_actions>B<,>\n"
91 "B< const posix_spawnattr_t *restrict >I<attrp>B<,>\n"
92 "B< char *const >I<argv>B<[restrict],>\n"
93 "B< char *const >I<envp>B<[restrict]);>\n"
94 msgstr ""
95
96 #. type: SH
97 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
98 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
99 #, no-wrap
100 msgid "DESCRIPTION"
101 msgstr ""
102
103 #. type: Plain text
104 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
105 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
106 msgid ""
107 "The B<posix_spawn>() and B<posix_spawnp>() functions are used to create a "
108 "new child process that executes a specified file. These functions were "
109 "specified by POSIX to provide a standardized method of creating new "
110 "processes on machines that lack the capability to support the B<fork>(2) "
111 "system call. These machines are generally small, embedded systems lacking "
112 "MMU support."
113 msgstr ""
114
115 #. type: Plain text
116 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
117 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
118 msgid ""
119 "The B<posix_spawn>() and B<posix_spawnp>() functions provide the "
120 "functionality of a combined B<fork>(2) and B<exec>(3), with some optional "
121 "housekeeping steps in the child process before the B<exec>(3). These "
122 "functions are not meant to replace the B<fork>(2) and B<execve>(2) system "
123 "calls. In fact, they provide only a subset of the functionality that can be "
124 "achieved by using the system calls."
125 msgstr ""
126
127 #. type: Plain text
128 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
129 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
130 msgid ""
131 "The only difference between B<posix_spawn>() and B<posix_spawnp>() is the "
132 "manner in which they specify the file to be executed by the child process. "
133 "With B<posix_spawn>(), the executable file is specified as a pathname (which "
134 "can be absolute or relative). With B<posix_spawnp>(), the executable file "
135 "is specified as a simple filename; the system searches for this file in the "
136 "list of directories specified by B<PATH> (in the same way as for "
137 "B<execvp>(3)). For the remainder of this page, the discussion is phrased in "
138 "terms of B<posix_spawn>(), with the understanding that B<posix_spawnp>() "
139 "differs only on the point just described."
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 "The remaining arguments to these two functions are as follows:"
146 msgstr ""
147
148 #. type: TP
149 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
150 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
151 #, no-wrap
152 msgid "I<pid>"
153 msgstr ""
154
155 #. type: Plain text
156 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
157 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
158 msgid ""
159 "points to a buffer that is used to return the process ID of the new child "
160 "process."
161 msgstr ""
162
163 #. type: TP
164 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
165 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
166 #, no-wrap
167 msgid "I<file_actions>"
168 msgstr ""
169
170 #. type: Plain text
171 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
172 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
173 msgid ""
174 "points to a I<spawn file actions object> that specifies file-related actions "
175 "to be performed in the child between the B<fork>(2) and B<exec>(3) steps. "
176 "This object is initialized and populated before the B<posix_spawn>() call "
177 "using B<posix_spawn_file_actions_init>(3) and the "
178 "B<posix_spawn_file_actions_*>() functions."
179 msgstr ""
180
181 #. type: TP
182 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
183 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
184 #, no-wrap
185 msgid "I<attrp>"
186 msgstr ""
187
188 #. type: Plain text
189 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
190 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
191 msgid ""
192 "points to an I<attributes objects> that specifies various attributes of the "
193 "created child process. This object is initialized and populated before the "
194 "B<posix_spawn>() call using B<posix_spawnattr_init>(3) and the "
195 "B<posix_spawnattr_*>() functions."
196 msgstr ""
197
198 #. type: TP
199 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
200 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
201 #, no-wrap
202 msgid "I<argv>"
203 msgstr ""
204
205 #. type: TQ
206 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
207 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
208 #, no-wrap
209 msgid "I<envp>"
210 msgstr ""
211
212 #. type: Plain text
213 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
214 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
215 msgid ""
216 "specify the argument list and environment for the program that is executed "
217 "in the child process, as for B<execve>(2)."
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 "Below, the functions are described in terms of a three-step process: the "
225 "B<fork>() step, the pre-B<exec>() step (executed in the child), and the "
226 "B<exec>() step (executed in the child)."
227 msgstr ""
228
229 #. type: SS
230 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
231 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
232 #, no-wrap
233 msgid "fork() step"
234 msgstr ""
235
236 #. type: Plain text
237 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
238 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
239 msgid ""
240 "Since glibc 2.24, the B<posix_spawn>() function commences by calling "
241 "B<clone>(2) with B<CLONE_VM> and B<CLONE_VFORK> flags. Older "
242 "implementations use B<fork>(2), or possibly B<vfork>(2) (see below)."
243 msgstr ""
244
245 #. type: Plain text
246 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
247 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
248 msgid ""
249 "The PID of the new child process is placed in I<*pid>. The "
250 "B<posix_spawn>() function then returns control to the parent process."
251 msgstr ""
252
253 #. type: Plain text
254 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
255 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
256 msgid ""
257 "Subsequently, the parent can use one of the system calls described in "
258 "B<wait>(2) to check the status of the child process. If the child fails in "
259 "any of the housekeeping steps described below, or fails to execute the "
260 "desired file, it exits with a status of 127."
261 msgstr ""
262
263 #. type: Plain text
264 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
265 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
266 msgid ""
267 "Before glibc 2.24, the child process is created using B<vfork>(2) instead "
268 "of B<fork>(2) when either of the following is true:"
269 msgstr ""
270
271 #. type: IP
272 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
273 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
274 #, no-wrap
275 msgid "\\[bu]"
276 msgstr ""
277
278 #. type: Plain text
279 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
280 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
281 msgid ""
282 "the I<spawn-flags> element of the attributes object pointed to by I<attrp> "
283 "contains the GNU-specific flag B<POSIX_SPAWN_USEVFORK>; or"
284 msgstr ""
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 "I<file_actions> is NULL and the I<spawn-flags> element of the attributes "
291 "object pointed to by I<attrp> does I<not> contain B<POSIX_SPAWN_SETSIGMASK>, "
292 "B<POSIX_SPAWN_SETSIGDEF>, B<POSIX_SPAWN_SETSCHEDPARAM>, "
293 "B<POSIX_SPAWN_SETSCHEDULER>, B<POSIX_SPAWN_SETPGROUP>, or "
294 "B<POSIX_SPAWN_RESETIDS>."
295 msgstr ""
296
297 #. type: Plain text
298 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
299 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
300 msgid ""
301 "In other words, B<vfork>(2) is used if the caller requests it, or if there "
302 "is no cleanup expected in the child before it B<exec>(3)s the requested file."
303 msgstr ""
304
305 #. type: SS
306 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
307 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
308 #, no-wrap
309 msgid "pre-exec() step: housekeeping"
310 msgstr ""
311
312 #. type: Plain text
313 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
314 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
315 msgid ""
316 "In between the B<fork()> and the B<exec()> steps, a child process may need "
317 "to perform a set of housekeeping actions. The B<posix_spawn>() and "
318 "B<posix_spawnp>() functions support a small, well-defined set of system "
319 "tasks that the child process can accomplish before it executes the "
320 "executable file. These operations are controlled by the attributes object "
321 "pointed to by I<attrp> and the file actions object pointed to by "
322 "I<file_actions>. In the child, processing is done in the following sequence:"
323 msgstr ""
324
325 #. type: IP
326 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
327 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
328 #, no-wrap
329 msgid "(1)"
330 msgstr ""
331
332 #. type: Plain text
333 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
334 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
335 msgid ""
336 "Process attribute actions: signal mask, signal default handlers, scheduling "
337 "algorithm and parameters, process group, and effective user and group IDs "
338 "are changed as specified by the attributes object pointed to by I<attrp>."
339 msgstr ""
340
341 #. type: IP
342 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
343 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
344 #, no-wrap
345 msgid "(2)"
346 msgstr ""
347
348 #. type: Plain text
349 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
350 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
351 msgid ""
352 "File actions, as specified in the I<file_actions> argument, are performed in "
353 "the order that they were specified using calls to the "
354 "B<posix_spawn_file_actions_add*>() functions."
355 msgstr ""
356
357 #. type: IP
358 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
359 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
360 #, no-wrap
361 msgid "(3)"
362 msgstr ""
363
364 #. type: Plain text
365 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
366 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
367 msgid "File descriptors with the B<FD_CLOEXEC> flag set are closed."
368 msgstr ""
369
370 #. type: Plain text
371 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
372 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
373 msgid ""
374 "All process attributes in the child, other than those affected by attributes "
375 "specified in the object pointed to by I<attrp> and the file actions in the "
376 "object pointed to by I<file_actions>, will be affected as though the child "
377 "was created with B<fork>(2) and it executed the program with B<execve>(2)."
378 msgstr ""
379
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 "The process attributes actions are defined by the attributes object pointed "
385 "to by I<attrp>. The I<spawn-flags> attribute (set using "
386 "B<posix_spawnattr_setflags>(3)) controls the general actions that occur, "
387 "and other attributes in the object specify values to be used during those "
388 "actions."
389 msgstr ""
390
391 #. type: Plain text
392 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
393 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
394 msgid ""
395 "The effects of the flags that may be specified in I<spawn-flags> are as "
396 "follows:"
397 msgstr ""
398
399 #. type: TP
400 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
401 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
402 #, no-wrap
403 msgid "B<POSIX_SPAWN_SETSIGMASK>"
404 msgstr ""
405
406 #. FIXME .
407 #. (see
408 #. .BR posix_spawnattr_setsigmask (3))
409 #. type: Plain text
410 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
411 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
412 msgid ""
413 "Set the signal mask to the signal set specified in the I<spawn-sigmask> "
414 "attribute of the object pointed to by I<attrp>. If the "
415 "B<POSIX_SPAWN_SETSIGMASK> flag is not set, then the child inherits the "
416 "parent's signal mask."
417 msgstr ""
418
419 #. type: TP
420 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
421 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
422 #, no-wrap
423 msgid "B<POSIX_SPAWN_SETSIGDEF>"
424 msgstr ""
425
426 #. FIXME .
427 #. (see
428 #. .BR posix_spawnattr_setsigdefault (3))
429 #. type: Plain text
430 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
431 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
432 msgid ""
433 "Reset the disposition of all signals in the set specified in the I<spawn-"
434 "sigdefault> attribute of the object pointed to by I<attrp> to the default. "
435 "For the treatment of the dispositions of signals not specified in the "
436 "I<spawn-sigdefault> attribute, or the treatment when "
437 "B<POSIX_SPAWN_SETSIGDEF> is not specified, see B<execve>(2)."
438 msgstr ""
439
440 #. type: TP
441 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
442 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
443 #, no-wrap
444 msgid "B<POSIX_SPAWN_SETSCHEDPARAM>"
445 msgstr ""
446
447 #. (POSIX_PRIORITY_SCHEDULING only)
448 #. FIXME .
449 #. (see
450 #. .BR posix_spawnattr_setschedparam (3))
451 #. type: Plain text
452 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
453 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
454 msgid ""
455 "If this flag is set, and the B<POSIX_SPAWN_SETSCHEDULER> flag is not set, "
456 "then set the scheduling parameters to the parameters specified in the "
457 "I<spawn-schedparam> attribute of the object pointed to by I<attrp>."
458 msgstr ""
459
460 #. type: TP
461 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
462 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
463 #, no-wrap
464 msgid "B<POSIX_SPAWN_SETSCHEDULER>"
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 "Set the scheduling policy algorithm and parameters of the child, as follows:"
472 msgstr ""
473
474 #. FIXME .
475 #. (see
476 #. .BR posix_spawnattr_setpolicy (3))
477 #. type: Plain text
478 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
479 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
480 msgid ""
481 "The scheduling policy is set to the value specified in the I<spawn-"
482 "schedpolicy> attribute of the object pointed to by I<attrp>."
483 msgstr ""
484
485 #. FIXME .
486 #. (see
487 #. .BR posix_spawnattr_setschedparam (3))
488 #. type: Plain text
489 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
490 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
491 msgid ""
492 "The scheduling parameters are set to the value specified in the I<spawn-"
493 "schedparam> attribute of the object pointed to by I<attrp> (but see BUGS)."
494 msgstr ""
495
496 #. type: Plain text
497 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
498 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
499 msgid ""
500 "If the B<POSIX_SPAWN_SETSCHEDPARAM> and B<POSIX_SPAWN_SETSCHEDPOLICY> flags "
501 "are not specified, the child inherits the corresponding scheduling "
502 "attributes from the parent."
503 msgstr ""
504
505 #. type: TP
506 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
507 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
508 #, no-wrap
509 msgid "B<POSIX_SPAWN_RESETIDS>"
510 msgstr ""
511
512 #. type: Plain text
513 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
514 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
515 msgid ""
516 "If this flag is set, reset the effective UID and GID to the real UID and GID "
517 "of the parent process. If this flag is not set, then the child retains the "
518 "effective UID and GID of the parent. In either case, if the set-user-ID and "
519 "set-group-ID permission bits are enabled on the executable file, their "
520 "effect will override the setting of the effective UID and GID (se "
521 "B<execve>(2))."
522 msgstr ""
523
524 #. type: TP
525 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
526 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
527 #, no-wrap
528 msgid "B<POSIX_SPAWN_SETPGROUP>"
529 msgstr ""
530
531 #. FIXME .
532 #. (see
533 #. .BR posix_spawnattr_setpgroup (3))
534 #. type: Plain text
535 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
536 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
537 msgid ""
538 "Set the process group to the value specified in the I<spawn-pgroup> "
539 "attribute of the object pointed to by I<attrp>. If the I<spawn-pgroup> "
540 "attribute has the value 0, the child's process group ID is made the same as "
541 "its process ID. If the B<POSIX_SPAWN_SETPGROUP> flag is not set, the child "
542 "inherits the parent's process group ID."
543 msgstr ""
544
545 #. type: TP
546 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
547 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
548 #, no-wrap
549 msgid "B<POSIX_SPAWN_USEVFORK>"
550 msgstr ""
551
552 #. type: Plain text
553 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
554 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
555 msgid ""
556 "Since glibc 2.24, this flag has no effect. On older implementations, "
557 "setting this flag forces the B<fork()> step to use B<vfork>(2) instead of "
558 "B<fork>(2). The B<_GNU_SOURCE> feature test macro must be defined to obtain "
559 "the definition of this constant."
560 msgstr ""
561
562 #. type: TP
563 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
564 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
565 #, no-wrap
566 msgid "B<POSIX_SPAWN_SETSID> (since glibc 2.26)"
567 msgstr ""
568
569 #. This flag has been accepted in POSIX, see:
570 #. http://austingroupbugs.net/view.php?id=1044
571 #. and has been implemented since glibc 2.26
572 #. commit daeb1fa2e1b33323e719015f5f546988bd4cc73b
573 #. type: Plain text
574 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
575 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
576 msgid ""
577 "If this flag is set, the child process shall create a new session and become "
578 "the session leader. The child process shall also become the process group "
579 "leader of the new process group in the session (see B<setsid>(2)). The "
580 "B<_GNU_SOURCE> feature test macro must be defined to obtain the definition "
581 "of this constant."
582 msgstr ""
583
584 #. mtk: I think we probably don't want to say the following, since it
585 #. could lead people to do the wrong thing
586 #. The POSIX standard tells you to call
587 #. this function to de-initialize the attributes object pointed to by
588 #. .I attrp
589 #. when you are done with it;
590 #. however, on Linux systems this operation is a no-op.
591 #. type: Plain text
592 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
593 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
594 msgid ""
595 "If I<attrp> is NULL, then the default behaviors described above for each "
596 "flag apply."
597 msgstr ""
598
599 #. type: Plain text
600 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
601 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
602 msgid ""
603 "The I<file_actions> argument specifies a sequence of file operations that "
604 "are performed in the child process after the general processing described "
605 "above, and before it performs the B<exec>(3). If I<file_actions> is NULL, "
606 "then no special action is taken, and standard B<exec>(3) semantics apply\\"
607 "[em]file descriptors open before the exec remain open in the new process, "
608 "except those for which the B<FD_CLOEXEC> flag has been set. File locks "
609 "remain in place."
610 msgstr ""
611
612 #. FIXME . I think the following is best placed in the
613 #. posix_spawn_file_actions_adddup2(3) page, and a similar statement is
614 #. also needed in posix_spawn_file_actions_addclose(3)
615 #. Note that you can specify file descriptors in
616 #. .I posix_spawn_file_actions_adddup2 (3)
617 #. which would not be usable if you called
618 #. .BR dup2 (2)
619 #. at that time--i.e., file descriptors that are opened or
620 #. closed by the earlier operations
621 #. added to
622 #. .I file_actions .
623 #. type: Plain text
624 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
625 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
626 msgid ""
627 "If I<file_actions> is not NULL, then it contains an ordered set of requests "
628 "to B<open>(2), B<close>(2), and B<dup2>(2) files. These requests are added "
629 "to the I<file_actions> by B<posix_spawn_file_actions_addopen>(3), "
630 "B<posix_spawn_file_actions_addclose>(3), and "
631 "B<posix_spawn_file_actions_adddup2>(3). The requested operations are "
632 "performed in the order they were added to I<file_actions>."
633 msgstr ""
634
635 #. type: Plain text
636 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
637 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
638 msgid ""
639 "If any of the housekeeping actions fails (due to bogus values being passed "
640 "or other reasons why signal handling, process scheduling, process group ID "
641 "functions, and file descriptor operations might fail), the child process "
642 "exits with exit value 127."
643 msgstr ""
644
645 #. type: SS
646 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
647 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
648 #, no-wrap
649 msgid "exec() step"
650 msgstr ""
651
652 #. type: Plain text
653 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
654 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
655 msgid ""
656 "Once the child has successfully forked and performed all requested pre-exec "
657 "steps, the child runs the requested executable."
658 msgstr ""
659
660 #. type: Plain text
661 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
662 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
663 msgid ""
664 "The child process takes its environment from the I<envp> argument, which is "
665 "interpreted as if it had been passed to B<execve>(2). The arguments to the "
666 "created process come from the I<argv> argument, which is processed as for "
667 "B<execve>(2)."
668 msgstr ""
669
670 #. type: SH
671 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
672 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
673 #, no-wrap
674 msgid "RETURN VALUE"
675 msgstr ""
676
677 #. type: Plain text
678 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
679 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
680 msgid ""
681 "Upon successful completion, B<posix_spawn>() and B<posix_spawnp>() place "
682 "the PID of the child process in I<pid>, and return 0. If there is an error "
683 "during the B<fork()> step, then no child is created, the contents of I<*pid> "
684 "are unspecified, and these functions return an error number as described "
685 "below."
686 msgstr ""
687
688 #. type: Plain text
689 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
690 #: opensuse-tumbleweed
691 msgid ""
692 "Even when these functions return a success status, the child process may "
693 "still fail for a plethora of reasons related to its pre-B<exec>() "
694 "initialization. In addition, the B<exec>(3) may fail. In all of these "
695 "cases, the child process will exit with the exit value of 127."
696 msgstr ""
697
698 #. type: SH
699 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
700 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
701 #, no-wrap
702 msgid "ERRORS"
703 msgstr ""
704
705 #. type: Plain text
706 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
707 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
708 msgid ""
709 "The B<posix_spawn>() and B<posix_spawnp>() functions fail only in the case "
710 "where the underlying B<fork>(2), B<vfork>(2), or B<clone>(2) call fails; in "
711 "these cases, these functions return an error number, which will be one of "
712 "the errors described for B<fork>(2), B<vfork>(2), or B<clone>(2)."
713 msgstr ""
714
715 #. type: Plain text
716 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
717 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
718 msgid "In addition, these functions fail if:"
719 msgstr ""
720
721 #. type: TP
722 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
723 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
724 #, no-wrap
725 msgid "B<ENOSYS>"
726 msgstr ""
727
728 #. type: Plain text
729 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
730 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
731 msgid "Function not supported on this system."
732 msgstr ""
733
734 #. type: SH
735 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
736 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
737 #, no-wrap
738 msgid "STANDARDS"
739 msgstr ""
740
741 #. type: Plain text
742 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
743 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
744 msgid "POSIX.1-2008."
745 msgstr ""
746
747 #. type: SH
748 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
749 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
750 #, no-wrap
751 msgid "HISTORY"
752 msgstr ""
753
754 #. FIXME . This piece belongs in spawnattr_setflags(3)
755 #. The
756 #. .B POSIX_SPAWN_USEVFORK
757 #. flag is a GNU extension; the
758 #. .B _GNU_SOURCE
759 #. feature test macro must be defined (before including any header files)
760 #. to obtain the definition of this constant.
761 #. type: Plain text
762 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
763 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
764 msgid "glibc 2.2. POSIX.1-2001."
765 msgstr ""
766
767 #. type: SH
768 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
769 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
770 #, no-wrap
771 msgid "NOTES"
772 msgstr ""
773
774 #. type: Plain text
775 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
776 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
777 msgid ""
778 "The housekeeping activities in the child are controlled by the objects "
779 "pointed to by I<attrp> (for non-file actions) and I<file_actions> In POSIX "
780 "parlance, the I<posix_spawnattr_t> and I<posix_spawn_file_actions_t> data "
781 "types are referred to as objects, and their elements are not specified by "
782 "name. Portable programs should initialize these objects using only the "
783 "POSIX-specified functions. (In other words, although these objects may be "
784 "implemented as structures containing fields, portable programs must avoid "
785 "dependence on such implementation details.)"
786 msgstr ""
787
788 #. Tested on glibc 2.12
789 #. type: Plain text
790 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
791 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
792 msgid ""
793 "According to POSIX, it is unspecified whether fork handlers established with "
794 "B<pthread_atfork>(3) are called when B<posix_spawn>() is invoked. Since "
795 "glibc 2.24, the fork handlers are not executed in any case. On older "
796 "implementations, fork handlers are called only if the child is created using "
797 "B<fork>(2)."
798 msgstr ""
799
800 #. type: Plain text
801 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
802 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
803 msgid ""
804 "There is no \"posix_fspawn\" function (i.e., a function that is to "
805 "B<posix_spawn>() as B<fexecve>(3) is to B<execve>(2)). However, this "
806 "functionality can be obtained by specifying the I<path> argument as one of "
807 "the files in the caller's I</proc/self/fd> directory."
808 msgstr ""
809
810 #. type: SH
811 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
812 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
813 #, no-wrap
814 msgid "BUGS"
815 msgstr ""
816
817 #. http://sourceware.org/bugzilla/show_bug.cgi?id=12052
818 #. type: Plain text
819 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
820 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
821 msgid ""
822 "POSIX.1 says that when B<POSIX_SPAWN_SETSCHEDULER> is specified in I<spawn-"
823 "flags>, then the B<POSIX_SPAWN_SETSCHEDPARAM> (if present) is ignored. "
824 "However, before glibc 2.14, calls to B<posix_spawn>() failed with an error "
825 "if B<POSIX_SPAWN_SETSCHEDULER> was specified without also specifying "
826 "B<POSIX_SPAWN_SETSCHEDPARAM>."
827 msgstr ""
828
829 #. type: SH
830 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
831 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
832 #, no-wrap
833 msgid "EXAMPLES"
834 msgstr ""
835
836 #. type: Plain text
837 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
838 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
839 msgid ""
840 "The program below demonstrates the use of various functions in the POSIX "
841 "spawn API. The program accepts command-line attributes that can be used to "
842 "create file actions and attributes objects. The remaining command-line "
843 "arguments are used as the executable name and command-line arguments of the "
844 "program that is executed in the child."
845 msgstr ""
846
847 #. type: Plain text
848 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
849 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
850 msgid ""
851 "In the first run, the B<date>(1) command is executed in the child, and the "
852 "B<posix_spawn>() call employs no file actions or attributes objects."
853 msgstr ""
854
855 #. type: Plain text
856 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
857 #: opensuse-tumbleweed
858 #, no-wrap
859 msgid ""
860 "$B< ./a.out date>;\n"
861 "PID of child: 7634\n"
862 "Tue Feb 1 19:47:50 CEST 2011\n"
863 "Child status: exited, status=0\n"
864 msgstr ""
865
866 #. type: Plain text
867 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
868 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
869 msgid ""
870 "In the next run, the I<-c> command-line option is used to create a file "
871 "actions object that closes standard output in the child. Consequently, "
872 "B<date>(1) fails when trying to perform output and exits with a status of 1."
873 msgstr ""
874
875 #. type: Plain text
876 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
877 #: opensuse-tumbleweed
878 #, no-wrap
879 msgid ""
880 "$B< ./a.out -c date>;\n"
881 "PID of child: 7636\n"
882 "date: write error: Bad file descriptor\n"
883 "Child status: exited, status=1\n"
884 msgstr ""
885
886 #. type: Plain text
887 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
888 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
889 msgid ""
890 "In the next run, the I<-s> command-line option is used to create an "
891 "attributes object that specifies that all (blockable) signals in the child "
892 "should be blocked. Consequently, trying to kill child with the default "
893 "signal sent by B<kill>(1) (i.e., B<SIGTERM>) fails, because that signal is "
894 "blocked. Therefore, to kill the child, B<SIGKILL> is necessary (B<SIGKILL> "
895 "can't be blocked)."
896 msgstr ""
897
898 #. type: Plain text
899 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
900 #: opensuse-tumbleweed
901 #, no-wrap
902 msgid ""
903 "$B< ./a.out -s sleep 60 &>\n"
904 "[1] 7637\n"
905 "$ PID of child: 7638\n"
906 msgstr ""
907
908 #. type: Plain text
909 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
910 #: opensuse-tumbleweed
911 #, no-wrap
912 msgid ""
913 "$B< kill 7638>;\n"
914 "$B< kill -KILL 7638>;\n"
915 "$ Child status: killed by signal 9\n"
916 "[1]+ Done ./a.out -s sleep 60\n"
917 msgstr ""
918
919 #. type: Plain text
920 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
921 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
922 msgid ""
923 "When we try to execute a nonexistent command in the child, the B<exec>(3) "
924 "fails and the child exits with a status of 127."
925 msgstr ""
926
927 #. type: Plain text
928 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
929 #: opensuse-tumbleweed
930 #, no-wrap
931 msgid ""
932 "$B< ./a.out xxxxx>;\n"
933 "PID of child: 10190\n"
934 "Child status: exited, status=127\n"
935 msgstr ""
936
937 #. type: SS
938 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
939 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
940 #, no-wrap
941 msgid "Program source"
942 msgstr ""
943
944 #. type: Plain text
945 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
946 #: opensuse-tumbleweed
947 #, no-wrap
948 msgid ""
949 "#include E<lt>err.hE<gt>\n"
950 "#include E<lt>errno.hE<gt>\n"
951 "#include E<lt>spawn.hE<gt>\n"
952 "#include E<lt>stdint.hE<gt>\n"
953 "#include E<lt>stdio.hE<gt>\n"
954 "#include E<lt>stdlib.hE<gt>\n"
955 "#include E<lt>string.hE<gt>\n"
956 "#include E<lt>unistd.hE<gt>\n"
957 "#include E<lt>wait.hE<gt>\n"
958 "\\&\n"
959 "char **environ;\n"
960 "\\&\n"
961 "int\n"
962 "main(int argc, char *argv[])\n"
963 "{\n"
964 " pid_t child_pid;\n"
965 " int s, opt, status;\n"
966 " sigset_t mask;\n"
967 " posix_spawnattr_t attr;\n"
968 " posix_spawnattr_t *attrp;\n"
969 " posix_spawn_file_actions_t file_actions;\n"
970 " posix_spawn_file_actions_t *file_actionsp;\n"
971 "\\&\n"
972 " /* Parse command-line options, which can be used to specify an\n"
973 " attributes object and file actions object for the child. */\n"
974 "\\&\n"
975 " attrp = NULL;\n"
976 " file_actionsp = NULL;\n"
977 "\\&\n"
978 " while ((opt = getopt(argc, argv, \"sc\")) != -1) {\n"
979 " switch (opt) {\n"
980 " case \\[aq]c\\[aq]: /* -c: close standard output in child */\n"
981 "\\&\n"
982 " /* Create a file actions object and add a \"close\"\n"
983 " action to it. */\n"
984 "\\&\n"
985 " s = posix_spawn_file_actions_init(&file_actions);\n"
986 " if (s != 0)\n"
987 " errc(EXIT_FAILURE, s, \"posix_spawn_file_actions_init\");\n"
988 "\\&\n"
989 " s = posix_spawn_file_actions_addclose(&file_actions,\n"
990 " STDOUT_FILENO);\n"
991 " if (s != 0)\n"
992 " errc(EXIT_FAILURE, s, \"posix_spawn_file_actions_addclose\");\n"
993 "\\&\n"
994 " file_actionsp = &file_actions;\n"
995 " break;\n"
996 "\\&\n"
997 " case \\[aq]s\\[aq]: /* -s: block all signals in child */\n"
998 "\\&\n"
999 " /* Create an attributes object and add a \"set signal mask\"\n"
1000 " action to it. */\n"
1001 "\\&\n"
1002 " s = posix_spawnattr_init(&attr);\n"
1003 " if (s != 0)\n"
1004 " errc(EXIT_FAILURE, s, \"posix_spawnattr_init\");\n"
1005 " s = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK);\n"
1006 " if (s != 0)\n"
1007 " errc(EXIT_FAILURE, s, \"posix_spawnattr_setflags\");\n"
1008 "\\&\n"
1009 " sigfillset(&mask);\n"
1010 " s = posix_spawnattr_setsigmask(&attr, &mask);\n"
1011 " if (s != 0)\n"
1012 " errc(EXIT_FAILURE, s, \"posix_spawnattr_setsigmask\");\n"
1013 "\\&\n"
1014 " attrp = &attr;\n"
1015 " break;\n"
1016 " }\n"
1017 " }\n"
1018 "\\&\n"
1019 " if (argv[optind] == NULL) {\n"
1020 " fprintf(stderr, \"Usage: %s [-cs] executable [args]\\[rs]n\", argv[0]);\n"
1021 " exit(EXIT_FAILURE);\n"
1022 " }\n"
1023 "\\&\n"
1024 " /* Spawn the child. The name of the program to execute and the\n"
1025 " command-line arguments are taken from the command-line arguments\n"
1026 " of this program. The environment of the program execed in the\n"
1027 " child is made the same as the parent\\[aq]s environment. */\n"
1028 "\\&\n"
1029 " s = posix_spawnp(&child_pid, argv[optind], file_actionsp, attrp,\n"
1030 " &argv[optind], environ);\n"
1031 " if (s != 0)\n"
1032 " errc(EXIT_FAILURE, s, \"posix_spawn\");\n"
1033 "\\&\n"
1034 " /* Destroy any objects that we created earlier. */\n"
1035 "\\&\n"
1036 " if (attrp != NULL) {\n"
1037 " s = posix_spawnattr_destroy(attrp);\n"
1038 " if (s != 0)\n"
1039 " errc(EXIT_FAILURE, s, \"posix_spawnattr_destroy\");\n"
1040 " }\n"
1041 "\\&\n"
1042 " if (file_actionsp != NULL) {\n"
1043 " s = posix_spawn_file_actions_destroy(file_actionsp);\n"
1044 " if (s != 0)\n"
1045 " errc(EXIT_FAILURE, s, \"posix_spawn_file_actions_destroy\");\n"
1046 " }\n"
1047 "\\&\n"
1048 " printf(\"PID of child: %jd\\[rs]n\", (intmax_t) child_pid);\n"
1049 "\\&\n"
1050 " /* Monitor status of the child until it terminates. */\n"
1051 "\\&\n"
1052 " do {\n"
1053 " s = waitpid(child_pid, &status, WUNTRACED | WCONTINUED);\n"
1054 " if (s == -1)\n"
1055 " err(EXIT_FAILURE, \"waitpid\");\n"
1056 "\\&\n"
1057 " printf(\"Child status: \");\n"
1058 " if (WIFEXITED(status)) {\n"
1059 " printf(\"exited, status=%d\\[rs]n\", WEXITSTATUS(status));\n"
1060 " } else if (WIFSIGNALED(status)) {\n"
1061 " printf(\"killed by signal %d\\[rs]n\", WTERMSIG(status));\n"
1062 " } else if (WIFSTOPPED(status)) {\n"
1063 " printf(\"stopped by signal %d\\[rs]n\", WSTOPSIG(status));\n"
1064 " } else if (WIFCONTINUED(status)) {\n"
1065 " printf(\"continued\\[rs]n\");\n"
1066 " }\n"
1067 " } while (!WIFEXITED(status) && !WIFSIGNALED(status));\n"
1068 "\\&\n"
1069 " exit(EXIT_SUCCESS);\n"
1070 "}\n"
1071 msgstr ""
1072
1073 #. SRC END
1074 #. type: SH
1075 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1076 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1077 #, no-wrap
1078 msgid "SEE ALSO"
1079 msgstr ""
1080
1081 #. type: Plain text
1082 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1083 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1084 msgid ""
1085 "B<close>(2), B<dup2>(2), B<execl>(2), B<execlp>(2), B<fork>(2), B<open>(2), "
1086 "B<sched_setparam>(2), B<sched_setscheduler>(2), B<setpgid>(2), B<setuid>(2), "
1087 "B<sigaction>(2), B<sigprocmask>(2), B<posix_spawn_file_actions_addclose>(3), "
1088 "B<posix_spawn_file_actions_adddup2>(3), "
1089 "B<posix_spawn_file_actions_addopen>(3), "
1090 "B<posix_spawn_file_actions_destroy>(3), B<posix_spawn_file_actions_init>(3), "
1091 "B<posix_spawnattr_destroy>(3), B<posix_spawnattr_getflags>(3), "
1092 "B<posix_spawnattr_getpgroup>(3), B<posix_spawnattr_getschedparam>(3), "
1093 "B<posix_spawnattr_getschedpolicy>(3), B<posix_spawnattr_getsigdefault>(3), "
1094 "B<posix_spawnattr_getsigmask>(3), B<posix_spawnattr_init>(3), "
1095 "B<posix_spawnattr_setflags>(3), B<posix_spawnattr_setpgroup>(3), "
1096 "B<posix_spawnattr_setschedparam>(3), B<posix_spawnattr_setschedpolicy>(3), "
1097 "B<posix_spawnattr_setsigdefault>(3), B<posix_spawnattr_setsigmask>(3), "
1098 "B<pthread_atfork>(3), I<E<lt>spawn.hE<gt>>, Base Definitions volume of "
1099 "POSIX.1-2001, I<http://www.opengroup.org/unix/online.html>"
1100 msgstr ""
1101
1102 #. type: TH
1103 #: debian-trixie
1104 #, no-wrap
1105 msgid "2024-06-15"
1106 msgstr ""
1107
1108 #. type: TH
1109 #: debian-trixie
1110 #, no-wrap
1111 msgid "Linux man-pages 6.9.1"
1112 msgstr ""
1113
1114 #. type: Plain text
1115 #: debian-trixie
1116 msgid "Standard C library (I<libc>, I<-lc>)"
1117 msgstr ""
1118
1119 #. type: Plain text
1120 #: debian-trixie fedora-44 fedora-rawhide
1121 msgid ""
1122 "Even when these functions return a success status, the child process may "
1123 "still fail for a plethora of reasons related to its pre-B<exec>() "
1124 "initialization. In addition, the B<exec>(3) may fail. In all of these "
1125 "cases, the child process will exit with the exit value of 127."
1126 msgstr ""
1127
1128 #. type: Plain text
1129 #: debian-trixie fedora-44 fedora-rawhide
1130 #, no-wrap
1131 msgid ""
1132 "$ B<./a.out date>\n"
1133 "PID of child: 7634\n"
1134 "Tue Feb 1 19:47:50 CEST 2011\n"
1135 "Child status: exited, status=0\n"
1136 msgstr ""
1137
1138 #. type: Plain text
1139 #: debian-trixie fedora-44 fedora-rawhide
1140 #, no-wrap
1141 msgid ""
1142 "$ B<./a.out -c date>\n"
1143 "PID of child: 7636\n"
1144 "date: write error: Bad file descriptor\n"
1145 "Child status: exited, status=1\n"
1146 msgstr ""
1147
1148 #. type: Plain text
1149 #: debian-trixie fedora-44 fedora-rawhide
1150 #, no-wrap
1151 msgid ""
1152 "$ B<./a.out -s sleep 60 &>\n"
1153 "[1] 7637\n"
1154 "$ PID of child: 7638\n"
1155 msgstr ""
1156
1157 #. type: Plain text
1158 #: debian-trixie fedora-44 fedora-rawhide
1159 #, no-wrap
1160 msgid ""
1161 "$ B<kill 7638>\n"
1162 "$ B<kill -KILL 7638>\n"
1163 "$ Child status: killed by signal 9\n"
1164 "[1]+ Done ./a.out -s sleep 60\n"
1165 msgstr ""
1166
1167 #. type: Plain text
1168 #: debian-trixie fedora-44 fedora-rawhide
1169 #, no-wrap
1170 msgid ""
1171 "$ B<./a.out xxxxx\n"
1172 "PID of child: 10190\n"
1173 "Child status: exited, status=127>\n"
1174 msgstr ""
1175
1176 #. type: Plain text
1177 #: debian-trixie fedora-44 fedora-rawhide
1178 #, no-wrap
1179 msgid ""
1180 "#include E<lt>errno.hE<gt>\n"
1181 "#include E<lt>spawn.hE<gt>\n"
1182 "#include E<lt>stdint.hE<gt>\n"
1183 "#include E<lt>stdio.hE<gt>\n"
1184 "#include E<lt>stdlib.hE<gt>\n"
1185 "#include E<lt>string.hE<gt>\n"
1186 "#include E<lt>unistd.hE<gt>\n"
1187 "#include E<lt>wait.hE<gt>\n"
1188 "\\&\n"
1189 "#define errExit(msg) do { perror(msg); \\[rs]\n"
1190 " exit(EXIT_FAILURE); } while (0)\n"
1191 "\\&\n"
1192 "#define errExitEN(en, msg) \\[rs]\n"
1193 " do { errno = en; perror(msg); \\[rs]\n"
1194 " exit(EXIT_FAILURE); } while (0)\n"
1195 "\\&\n"
1196 "char **environ;\n"
1197 "\\&\n"
1198 "int\n"
1199 "main(int argc, char *argv[])\n"
1200 "{\n"
1201 " pid_t child_pid;\n"
1202 " int s, opt, status;\n"
1203 " sigset_t mask;\n"
1204 " posix_spawnattr_t attr;\n"
1205 " posix_spawnattr_t *attrp;\n"
1206 " posix_spawn_file_actions_t file_actions;\n"
1207 " posix_spawn_file_actions_t *file_actionsp;\n"
1208 "\\&\n"
1209 " /* Parse command-line options, which can be used to specify an\n"
1210 " attributes object and file actions object for the child. */\n"
1211 "\\&\n"
1212 " attrp = NULL;\n"
1213 " file_actionsp = NULL;\n"
1214 "\\&\n"
1215 " while ((opt = getopt(argc, argv, \"sc\")) != -1) {\n"
1216 " switch (opt) {\n"
1217 " case \\[aq]c\\[aq]: /* -c: close standard output in child */\n"
1218 "\\&\n"
1219 " /* Create a file actions object and add a \"close\"\n"
1220 " action to it. */\n"
1221 "\\&\n"
1222 " s = posix_spawn_file_actions_init(&file_actions);\n"
1223 " if (s != 0)\n"
1224 " errExitEN(s, \"posix_spawn_file_actions_init\");\n"
1225 "\\&\n"
1226 " s = posix_spawn_file_actions_addclose(&file_actions,\n"
1227 " STDOUT_FILENO);\n"
1228 " if (s != 0)\n"
1229 " errExitEN(s, \"posix_spawn_file_actions_addclose\");\n"
1230 "\\&\n"
1231 " file_actionsp = &file_actions;\n"
1232 " break;\n"
1233 "\\&\n"
1234 " case \\[aq]s\\[aq]: /* -s: block all signals in child */\n"
1235 "\\&\n"
1236 " /* Create an attributes object and add a \"set signal mask\"\n"
1237 " action to it. */\n"
1238 "\\&\n"
1239 " s = posix_spawnattr_init(&attr);\n"
1240 " if (s != 0)\n"
1241 " errExitEN(s, \"posix_spawnattr_init\");\n"
1242 " s = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK);\n"
1243 " if (s != 0)\n"
1244 " errExitEN(s, \"posix_spawnattr_setflags\");\n"
1245 "\\&\n"
1246 " sigfillset(&mask);\n"
1247 " s = posix_spawnattr_setsigmask(&attr, &mask);\n"
1248 " if (s != 0)\n"
1249 " errExitEN(s, \"posix_spawnattr_setsigmask\");\n"
1250 "\\&\n"
1251 " attrp = &attr;\n"
1252 " break;\n"
1253 " }\n"
1254 " }\n"
1255 "\\&\n"
1256 " /* Spawn the child. The name of the program to execute and the\n"
1257 " command-line arguments are taken from the command-line arguments\n"
1258 " of this program. The environment of the program execed in the\n"
1259 " child is made the same as the parent\\[aq]s environment. */\n"
1260 "\\&\n"
1261 " s = posix_spawnp(&child_pid, argv[optind], file_actionsp, attrp,\n"
1262 " &argv[optind], environ);\n"
1263 " if (s != 0)\n"
1264 " errExitEN(s, \"posix_spawn\");\n"
1265 "\\&\n"
1266 " /* Destroy any objects that we created earlier. */\n"
1267 "\\&\n"
1268 " if (attrp != NULL) {\n"
1269 " s = posix_spawnattr_destroy(attrp);\n"
1270 " if (s != 0)\n"
1271 " errExitEN(s, \"posix_spawnattr_destroy\");\n"
1272 " }\n"
1273 "\\&\n"
1274 " if (file_actionsp != NULL) {\n"
1275 " s = posix_spawn_file_actions_destroy(file_actionsp);\n"
1276 " if (s != 0)\n"
1277 " errExitEN(s, \"posix_spawn_file_actions_destroy\");\n"
1278 " }\n"
1279 "\\&\n"
1280 " printf(\"PID of child: %jd\\[rs]n\", (intmax_t) child_pid);\n"
1281 "\\&\n"
1282 " /* Monitor status of the child until it terminates. */\n"
1283 "\\&\n"
1284 " do {\n"
1285 " s = waitpid(child_pid, &status, WUNTRACED | WCONTINUED);\n"
1286 " if (s == -1)\n"
1287 " errExit(\"waitpid\");\n"
1288 "\\&\n"
1289 " printf(\"Child status: \");\n"
1290 " if (WIFEXITED(status)) {\n"
1291 " printf(\"exited, status=%d\\[rs]n\", WEXITSTATUS(status));\n"
1292 " } else if (WIFSIGNALED(status)) {\n"
1293 " printf(\"killed by signal %d\\[rs]n\", WTERMSIG(status));\n"
1294 " } else if (WIFSTOPPED(status)) {\n"
1295 " printf(\"stopped by signal %d\\[rs]n\", WSTOPSIG(status));\n"
1296 " } else if (WIFCONTINUED(status)) {\n"
1297 " printf(\"continued\\[rs]n\");\n"
1298 " }\n"
1299 " } while (!WIFEXITED(status) && !WIFSIGNALED(status));\n"
1300 "\\&\n"
1301 " exit(EXIT_SUCCESS);\n"
1302 "}\n"
1303 msgstr ""
1304
1305 #. type: TH
1306 #: fedora-44 fedora-rawhide
1307 #, no-wrap
1308 msgid "2024-07-23"
1309 msgstr ""
1310
1311 #. type: TH
1312 #: fedora-44 fedora-rawhide
1313 #, no-wrap
1314 msgid "Linux man-pages 6.13"
1315 msgstr ""
1316
1317 #. type: TH
1318 #: mageia-cauldron
1319 #, no-wrap
1320 msgid "Linux man-pages 6.17"
1321 msgstr ""
1322
1323 #. type: TH
1324 #: opensuse-leap-16-1 opensuse-tumbleweed
1325 #, no-wrap
1326 msgid "Linux man-pages (unreleased)"
1327 msgstr ""