malloc.3: ffix
[man-pages.git] / man3 / posix_spawn.3
blob28767c4671708709e502b9dcfb9768b3d5fcc155
1 .\" Copyright (c) 2009 Bill O. Gallmeister (bgallmeister@gmail.com)
2 .\" and Copyright 2010 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" References consulted:
27 .\"     Linux glibc source code
28 .\"     POSIX 1003.1-2004 documentation
29 .\"     (http://www.opengroup.org/onlinepubs/009695399)
30 .\"
31 .TH POSIX_SPAWN 3 2021-03-22 "GNU" "Linux Programmer's Manual"
32 .SH NAME
33 posix_spawn, posix_spawnp \- spawn a process
34 .SH SYNOPSIS
35 .nf
36 .B #include <spawn.h>
37 .PP
38 .BI "int posix_spawn(pid_t *restrict " pid ", const char *restrict " path ,
39 .BI "                const posix_spawn_file_actions_t *restrict " file_actions ,
40 .BI "                const posix_spawnattr_t *restrict " attrp ,
41 .BI "                char *const " argv [restrict],
42 .BI "                char *const " envp [restrict]);
43 .BI "int posix_spawnp(pid_t *restrict " pid ", const char *restrict " file ,
44 .BI "                const posix_spawn_file_actions_t *restrict " file_actions ,
45 .BI "                const posix_spawnattr_t *restrict " attrp ,
46 .BI "                char *const " argv [restrict],
47 .BI "                char *const " envp [restrict]);
48 .fi
49 .SH DESCRIPTION
50 The
51 .BR posix_spawn ()
52 and
53 .BR posix_spawnp ()
54 functions are used to create a new child process that executes
55 a specified file.
56 These functions were specified by POSIX to provide a standardized method
57 of creating new processes on machines that lack the capability
58 to support the
59 .BR fork (2)
60 system call.
61 These machines are generally small, embedded systems lacking MMU support.
62 .PP
63 The
64 .BR posix_spawn ()
65 and
66 .BR posix_spawnp ()
67 functions provide the functionality of a combined
68 .BR fork (2)
69 and
70 .BR exec (3),
71 with some optional housekeeping steps in the child process before the
72 .BR exec (3).
73 These functions are not meant to replace the
74 .BR fork (2)
75 and
76 .BR execve (2)
77 system calls.
78 In fact, they provide only a subset of the functionality
79 that can be achieved by using the system calls.
80 .PP
81 The only difference between
82 .BR posix_spawn ()
83 and
84 .BR posix_spawnp ()
85 is the manner in which they specify the file to be executed by
86 the child process.
87 With
88 .BR posix_spawn (),
89 the executable file is specified as a pathname
90 (which can be absolute or relative).
91 With
92 .BR posix_spawnp (),
93 the executable file is specified as a simple filename;
94 the system searches for this file in the list of directories specified by
95 .BR PATH
96 (in the same way as for
97 .BR execvp (3)).
98 For the remainder of this page, the discussion is phrased in terms of
99 .BR posix_spawn (),
100 with the understanding that
101 .BR posix_spawnp ()
102 differs only on the point just described.
104 The remaining arguments to these two functions are as follows:
105 .IP * 3
107 .I pid
108 argument points to a buffer that is used to return the process ID
109 of the new child process.
110 .IP *
112 .I file_actions
113 argument points to a
114 .I "spawn file actions object"
115 that specifies file-related actions to be performed in the child
116 between the
117 .BR fork (2)
119 .BR exec (3)
120 steps.
121 This object is initialized and populated before the
122 .BR posix_spawn ()
123 call using
124 .BR posix_spawn_file_actions_init (3)
125 and the
126 .BR posix_spawn_file_actions_* ()
127 functions.
128 .IP *
130 .I attrp
131 argument points to an
132 .I attributes objects
133 that specifies various attributes of the created child process.
134 This object is initialized and populated before the
135 .BR posix_spawn ()
136 call using
137 .BR posix_spawnattr_init (3)
138 and the
139 .BR posix_spawnattr_* ()
140 functions.
141 .IP *
143 .I argv
145 .I envp
146 arguments specify the argument list and environment for the program
147 that is executed in the child process, as for
148 .BR execve (2).
150 Below, the functions are described in terms of a three-step process: the
151 .BR fork ()
152 step, the
153 .RB pre- exec ()
154 step (executed in the child),
155 and the
156 .BR exec ()
157 step (executed in the child).
158 .SS fork() step
159 Since glibc 2.24, the
160 .BR posix_spawn ()
161 function commences by calling
162 .BR clone (2)
163 with
164 .BR CLONE_VM
166 .BR CLONE_VFORK
167 flags.
168 Older implementations use
169 .BR fork (2),
170 or possibly
171 .BR vfork (2)
172 (see below).
174 The PID of the new child process is placed in
175 .IR *pid .
177 .BR posix_spawn ()
178 function then returns control to the parent process.
180 Subsequently, the parent can use one of the system calls described in
181 .BR wait (2)
182 to check the status of the child process.
183 If the child fails in any of the housekeeping steps described below,
184 or fails to execute the desired file,
185 it exits with a status of 127.
187 Before glibc 2.24, the child process is created using
188 .BR vfork (2)
189 instead of
190 .BR fork (2)
191 when either of the following is true:
192 .IP * 3
194 .I spawn-flags
195 element of the attributes object pointed to by
196 .I attrp
197 contains the GNU-specific flag
198 .BR POSIX_SPAWN_USEVFORK ;
200 .IP *
201 .I file_actions
202 is NULL and the
203 .I spawn-flags
204 element of the attributes object pointed to by
205 .I attrp
206 does \fInot\fP contain
207 .BR POSIX_SPAWN_SETSIGMASK ,
208 .BR POSIX_SPAWN_SETSIGDEF ,
209 .BR POSIX_SPAWN_SETSCHEDPARAM ,
210 .BR POSIX_SPAWN_SETSCHEDULER ,
211 .BR POSIX_SPAWN_SETPGROUP ,
213 .BR POSIX_SPAWN_RESETIDS .
215 In other words,
216 .BR vfork (2)
217 is used if the caller requests it,
218 or if there is no cleanup expected in the child before it
219 .BR exec (3)s
220 the requested file.
221 .SS pre-exec() step: housekeeping
222 In between the
223 .BR fork()
224 and the
225 .BR exec()
226 steps, a child process may need to perform a set of housekeeping actions.
228 .BR posix_spawn ()
230 .BR posix_spawnp ()
231 functions support a small, well-defined set of system tasks that the child
232 process can accomplish before it executes the executable file.
233 These operations are controlled by the attributes object pointed to by
234 .IR attrp
235 and the file actions object pointed to by
236 .IR file_actions .
237 In the child, processing is done in the following sequence:
238 .IP 1. 3
239 Process attribute actions: signal mask, signal default handlers,
240 scheduling algorithm and parameters,
241 process group, and effective user and group IDs
242 are changed as specified by the attributes object pointed to by
243 .IR attrp .
244 .IP 2.
245 File actions, as specified in the
246 .I file_actions
247 argument,
248 are performed in the order that they were specified using calls to the
249 .BR posix_spawn_file_actions_add* ()
250 functions.
251 .IP 3.
252 File descriptors with the
253 .B FD_CLOEXEC
254 flag set are closed.
256 All process attributes in the child,
257 other than those affected by attributes specified in the
258 object pointed to by
259 .IR attrp
260 and the file actions in the object pointed to by
261 .IR file_actions ,
262 will be affected as though the child was created with
263 .BR fork (2)
264 and it executed the program with
265 .BR execve (2).
267 The process attributes actions are defined by the attributes object
268 pointed to by
269 .IR attrp .
271 .I spawn-flags
272 attribute (set using
273 .BR posix_spawnattr_setflags (3))
274 controls the general actions that occur,
275 and other attributes in the object specify values
276 to be used during those actions.
278 The effects of the flags that may be specified in
279 .IR spawn-flags
280 are as follows:
282 .B POSIX_SPAWN_SETSIGMASK
283 Set the signal mask to the signal set specified in the
284 .I spawn-sigmask
285 attribute
286 .\" FIXME .
287 .\" (see
288 .\" .BR posix_spawnattr_setsigmask (3))
289 of the object pointed to by
290 .IR attrp .
291 If the
292 .B POSIX_SPAWN_SETSIGMASK
293 flag is not set, then the child inherits the parent's signal mask.
295 .B POSIX_SPAWN_SETSIGDEF
296 Reset the disposition of all signals in the set specified in the
297 .I spawn-sigdefault
298 attribute
299 .\" FIXME .
300 .\" (see
301 .\" .BR posix_spawnattr_setsigdefault (3))
302 of the object pointed to by
303 .IR attrp
304 to the default.
305 For the treatment of the dispositions of signals not specified in the
306 .I spawn-sigdefault
307 attribute, or the treatment when
308 .B POSIX_SPAWN_SETSIGDEF
309 is not specified, see
310 .BR execve (2).
312 .B POSIX_SPAWN_SETSCHEDPARAM
313 .\" (POSIX_PRIORITY_SCHEDULING only)
314 If this flag is set, and the
315 .B POSIX_SPAWN_SETSCHEDULER
316 flag is not set, then set the scheduling parameters
317 to the parameters specified in the
318 .I spawn-schedparam
319 attribute
320 .\" FIXME .
321 .\" (see
322 .\" .BR posix_spawnattr_setschedparam (3))
323 of the object pointed to by
324 .IR attrp .
326 .B POSIX_SPAWN_SETSCHEDULER
327 Set the scheduling policy algorithm and parameters of the child,
328 as follows:
330 .IP * 3
331 The scheduling policy is set to the value specified in the
332 .I spawn-schedpolicy
333 attribute
334 .\" FIXME .
335 .\" (see
336 .\" .BR posix_spawnattr_setpolicy (3))
337 of the object pointed to by
338 .IR attrp .
339 .IP *
340 The scheduling parameters are set to the value specified in the
341 .I spawn-schedparam
342 attribute
343 .\" FIXME .
344 .\" (see
345 .\" .BR posix_spawnattr_setschedparam (3))
346 of the object pointed to by
347 .IR attrp
348 (but see BUGS).
350 If the
351 .B POSIX_SPAWN_SETSCHEDPARAM
353 .B POSIX_SPAWN_SETSCHEDPOLICY
354 flags are not specified,
355 the child inherits the corresponding scheduling attributes from the parent.
358 .B POSIX_SPAWN_RESETIDS
359 If this flag is set,
360 reset the effective UID and GID to the
361 real UID and GID of the parent process.
362 If this flag is not set,
363 then the child retains the effective UID and GID of the parent.
364 In either case, if the set-user-ID and set-group-ID permission
365 bits are enabled on the executable file, their effect will override
366 the setting of the effective UID and GID (se
367 .BR execve (2)).
369 .B POSIX_SPAWN_SETPGROUP
370 Set the process group to the value specified in the
371 .I spawn-pgroup
372 attribute
373 .\" FIXME .
374 .\" (see
375 .\" .BR posix_spawnattr_setpgroup (3))
376 of the object pointed to by
377 .IR attrp .
378 If the
379 .I spawn-pgroup
380 attribute has the value 0,
381 the child's process group ID is made the same as its process ID.
382 If the
383 .B POSIX_SPAWN_SETPGROUP
384 flag is not set, the child inherits the parent's process group ID.
386 .B POSIX_SPAWN_USEVFORK
387 Since glibc 2.24, this flag has no effect.
388 On older implementations, setting this flag forces the
389 .BR fork()
390 step to use
391 .BR vfork (2)
392 instead of
393 .BR fork (2).
395 .B _GNU_SOURCE
396 feature test macro must be defined to obtain the definition of this constant.
398 .BR POSIX_SPAWN_SETSID " (since glibc 2.26)"
399 If this flag is set,
400 the child process shall create a new session and become the session leader.
401 The child process shall also become the process group leader of the new process
402 group in the session (see
403 .BR setsid (2)).
405 .B _GNU_SOURCE
406 feature test macro must be defined to obtain the definition of this constant.
407 .\" This flag has been accepted in POSIX, see:
408 .\" http://austingroupbugs.net/view.php?id=1044
409 .\" and has been implemented in glibc since version 2.26
410 .\" commit daeb1fa2e1b33323e719015f5f546988bd4cc73b
413 .I attrp
414 is NULL, then the default behaviors described above for each flag apply.
415 .\" mtk: I think we probably don't want to say the following, since it
416 .\"      could lead people to do the wrong thing
417 .\" The POSIX standard tells you to call
418 .\" this function to de-initialize the attributes object pointed to by
419 .\" .I attrp
420 .\" when you are done with it;
421 .\" however, on Linux systems this operation is a no-op.
424 .I file_actions
425 argument specifies a sequence of file operations
426 that are performed in the child process after
427 the general processing described above, and before it performs the
428 .BR exec (3).
430 .I file_actions
431 is NULL, then no special action is taken, and standard
432 .BR exec (3)
433 semantics apply\(emfile descriptors open before the exec
434 remain open in the new process,
435 except those for which the
436 .B FD_CLOEXEC
437 flag has been set.
438 File locks remain in place.
441 .I file_actions
442 is not NULL, then it contains an ordered set of requests to
443 .BR open (2),
444 .BR close (2),
446 .BR dup2 (2)
447 files.
448 These requests are added to the
449 .I file_actions
451 .BR posix_spawn_file_actions_addopen (3),
452 .BR posix_spawn_file_actions_addclose (3),
454 .BR posix_spawn_file_actions_adddup2 (3).
455 The requested operations are performed in the order they were added to
456 .IR file_actions .
457 .\" FIXME . I think the following is best placed in the
458 .\" posix_spawn_file_actions_adddup2(3) page, and a similar statement is
459 .\" also needed in posix_spawn_file_actions_addclose(3)
460 .\" Note that you can specify file descriptors in
461 .\" .I posix_spawn_file_actions_adddup2 (3)
462 .\" which would not be usable if you called
463 .\" .BR dup2 (2)
464 .\" at that time--i.e., file descriptors that are opened or
465 .\" closed by the earlier operations
466 .\" added to
467 .\" .I file_actions .
469 If any of the housekeeping actions fails
470 (due to bogus values being passed or other reasons why signal handling,
471 process scheduling, process group ID functions,
472 and file descriptor operations might fail),
473 the child process exits with exit value 127.
474 .SS exec() step
475 Once the child has successfully forked and performed
476 all requested pre-exec steps,
477 the child runs the requested executable.
479 The child process takes its environment from the
480 .I envp
481 argument, which is interpreted as if it had been passed to
482 .BR execve (2).
483 The arguments to the created process come from the
484 .I argv
485 argument, which is processed as for
486 .BR execve (2).
487 .SH RETURN VALUE
488 Upon successful completion,
489 .BR posix_spawn ()
491 .BR posix_spawnp ()
492 place the PID of the child process in
493 .IR pid ,
494 and return 0.
495 If there is an error during the
496 .BR fork()
497 step,
498 then no child is created,
499 the contents of
500 .IR *pid
501 are unspecified,
502 and these functions return an error number as described below.
504 Even when these functions return a success status,
505 the child process may still fail for a plethora of reasons related to its
506 pre-\fBexec\fR() initialization.
507 In addition, the
508 .BR exec (3)
509 may fail.
510 In all of these cases, the child process will exit with the exit value of 127.
511 .SH ERRORS
513 .BR posix_spawn ()
515 .BR posix_spawnp ()
516 functions fail only in the case where the underlying
517 .BR fork (2),
518 .BR vfork (2),
520 .BR clone (2)
521 call fails;  in these cases, these functions return an error number,
522 which will be one of the errors described for
523 .BR fork (2),
524 .BR vfork (2),
526 .BR clone (2).
528 In addition, these functions fail if:
530 .B ENOSYS
531 Function not supported on this system.
532 .SH VERSIONS
534 .BR posix_spawn ()
536 .BR posix_spawnp ()
537 functions are available since glibc 2.2.
538 .SH CONFORMING TO
539 POSIX.1-2001, POSIX.1-2008.
540 .\" FIXME . This piece belongs in spawnattr_setflags(3)
541 .\" The
542 .\" .B POSIX_SPAWN_USEVFORK
543 .\" flag is a GNU extension; the
544 .\" .B _GNU_SOURCE
545 .\" feature test macro must be defined (before including any header files)
546 .\" to obtain the definition of this constant.
547 .SH NOTES
548 The housekeeping activities in the child are controlled by
549 the objects pointed to by
550 .I attrp
551 (for non-file actions) and
552 .I file_actions
553 In POSIX parlance, the
554 .I posix_spawnattr_t
556 .I posix_spawn_file_actions_t
557 data types are referred to as objects,
558 and their elements are not specified by name.
559 Portable programs should initialize these objects using
560 only the POSIX-specified functions.
561 (In other words,
562 although these objects may be implemented as structures containing fields,
563 portable programs must avoid dependence on such implementation details.)
565 According to POSIX, it is unspecified whether fork handlers established with
566 .BR pthread_atfork (3)
567 are called when
568 .BR posix_spawn ()
569 is invoked.
570 Since glibc 2.24, the fork handlers are not executed in any case.
571 .\" Tested on glibc 2.12
572 On older implementations,
573 fork handlers are called only if the child is created using
574 .BR fork (2).
576 There is no "posix_fspawn" function (i.e., a function that is to
577 .BR posix_spawn ()
579 .BR fexecve (3)
580 is to
581 .BR execve (2)).
582 However, this functionality can be obtained by specifying the
583 .I path
584 argument as one of the files in the caller's
585 .IR /proc/self/fd
586 directory.
587 .SH BUGS
588 POSIX.1 says that when
589 .B POSIX_SPAWN_SETSCHEDULER
590 is specified in
591 .IR spawn-flags ,
592 then the
593 .B POSIX_SPAWN_SETSCHEDPARAM
594 (if present) is ignored.
595 However, before glibc 2.14, calls to
596 .BR posix_spawn ()
597 failed with an error if
598 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=12052
599 .BR POSIX_SPAWN_SETSCHEDULER
600 was specified without also specifying
601 .BR POSIX_SPAWN_SETSCHEDPARAM .
602 .SH EXAMPLES
603 The program below demonstrates the use of various functions in the
604 POSIX spawn API.
605 The program accepts command-line attributes that can be used
606 to create file actions and attributes objects.
607 The remaining command-line arguments are used as the executable name
608 and command-line arguments of the program that is executed in the child.
610 In the first run, the
611 .BR date (1)
612 command is executed in the child, and the
613 .BR posix_spawn ()
614 call employs no file actions or attributes objects.
616 .in +4n
618 $ \fB./a.out date\fP
619 PID of child: 7634
620 Tue Feb  1 19:47:50 CEST 2011
621 Child status: exited, status=0
625 In the next run, the
626 .I \-c
627 command-line option is used to create a file actions object that closes
628 standard output in the child.
629 Consequently,
630 .BR date (1)
631 fails when trying to perform output and exits with a status of 1.
633 .in +4n
635 $ \fB./a.out \-c date\fP
636 PID of child: 7636
637 date: write error: Bad file descriptor
638 Child status: exited, status=1
642 In the next run, the
643 .I \-s
644 command-line option is used to create an attributes object that
645 specifies that all (blockable) signals in the child should be blocked.
646 Consequently, trying to kill child with the default signal sent by
647 .BR kill (1)
648 (i.e.,
649 .BR SIGTERM )
650 fails, because that signal is blocked.
651 Therefore, to kill the child,
652 .BR SIGKILL
653 is necessary
654 .RB ( SIGKILL
655 can't be blocked).
657 .in +4n
659 $ \fB./a.out \-s sleep 60 &\fP
660 [1] 7637
661 $ PID of child: 7638
663 $ \fBkill 7638\fP
664 $ \fBkill \-KILL 7638\fP
665 $ Child status: killed by signal 9
666 [1]+  Done                    ./a.out \-s sleep 60
670 When we try to execute a nonexistent command in the child, the
671 .BR exec (3)
672 fails and the child exits with a status of 127.
674 .in +4n
676 $ \fB./a.out xxxxx
677 PID of child: 10190
678 Child status: exited, status=127
681 .SS Program source
684 #include <spawn.h>
685 #include <stdint.h>
686 #include <stdio.h>
687 #include <unistd.h>
688 #include <stdlib.h>
689 #include <string.h>
690 #include <wait.h>
691 #include <errno.h>
693 #define errExit(msg)    do { perror(msg); \e
694                              exit(EXIT_FAILURE); } while (0)
696 #define errExitEN(en, msg) \e
697                         do { errno = en; perror(msg); \e
698                              exit(EXIT_FAILURE); } while (0)
700 char **environ;
703 main(int argc, char *argv[])
705     pid_t child_pid;
706     int s, opt, status;
707     sigset_t mask;
708     posix_spawnattr_t attr;
709     posix_spawnattr_t *attrp;
710     posix_spawn_file_actions_t file_actions;
711     posix_spawn_file_actions_t *file_actionsp;
713     /* Parse command\-line options, which can be used to specify an
714        attributes object and file actions object for the child. */
716     attrp = NULL;
717     file_actionsp = NULL;
719     while ((opt = getopt(argc, argv, "sc")) != \-1) {
720         switch (opt) {
721         case \(aqc\(aq:       /* \-c: close standard output in child */
723             /* Create a file actions object and add a "close"
724                action to it. */
726             s = posix_spawn_file_actions_init(&file_actions);
727             if (s != 0)
728                 errExitEN(s, "posix_spawn_file_actions_init");
730             s = posix_spawn_file_actions_addclose(&file_actions,
731                                                   STDOUT_FILENO);
732             if (s != 0)
733                 errExitEN(s, "posix_spawn_file_actions_addclose");
735             file_actionsp = &file_actions;
736             break;
738         case \(aqs\(aq:       /* \-s: block all signals in child */
740             /* Create an attributes object and add a "set signal mask"
741                action to it. */
743             s = posix_spawnattr_init(&attr);
744             if (s != 0)
745                 errExitEN(s, "posix_spawnattr_init");
746             s = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK);
747             if (s != 0)
748                 errExitEN(s, "posix_spawnattr_setflags");
750             sigfillset(&mask);
751             s = posix_spawnattr_setsigmask(&attr, &mask);
752             if (s != 0)
753                 errExitEN(s, "posix_spawnattr_setsigmask");
755             attrp = &attr;
756             break;
757         }
758     }
760     /* Spawn the child. The name of the program to execute and the
761        command\-line arguments are taken from the command\-line arguments
762        of this program. The environment of the program execed in the
763        child is made the same as the parent\(aqs environment. */
765     s = posix_spawnp(&child_pid, argv[optind], file_actionsp, attrp,
766                      &argv[optind], environ);
767     if (s != 0)
768         errExitEN(s, "posix_spawn");
770     /* Destroy any objects that we created earlier. */
772     if (attrp != NULL) {
773         s = posix_spawnattr_destroy(attrp);
774         if (s != 0)
775             errExitEN(s, "posix_spawnattr_destroy");
776     }
778     if (file_actionsp != NULL) {
779         s = posix_spawn_file_actions_destroy(file_actionsp);
780         if (s != 0)
781             errExitEN(s, "posix_spawn_file_actions_destroy");
782     }
784     printf("PID of child: %jd\en", (intmax_t) child_pid);
786     /* Monitor status of the child until it terminates. */
788     do {
789         s = waitpid(child_pid, &status, WUNTRACED | WCONTINUED);
790         if (s == \-1)
791             errExit("waitpid");
793         printf("Child status: ");
794         if (WIFEXITED(status)) {
795             printf("exited, status=%d\en", WEXITSTATUS(status));
796         } else if (WIFSIGNALED(status)) {
797             printf("killed by signal %d\en", WTERMSIG(status));
798         } else if (WIFSTOPPED(status)) {
799             printf("stopped by signal %d\en", WSTOPSIG(status));
800         } else if (WIFCONTINUED(status)) {
801             printf("continued\en");
802         }
803     } while (!WIFEXITED(status) && !WIFSIGNALED(status));
805     exit(EXIT_SUCCESS);
808 .SH SEE ALSO
809 .nh \" Disable hyphenation
810 .ad l
811 .BR close (2),
812 .BR dup2 (2),
813 .BR execl (2),
814 .BR execlp (2),
815 .BR fork (2),
816 .BR open (2),
817 .BR sched_setparam (2),
818 .BR sched_setscheduler (2),
819 .BR setpgid (2),
820 .BR setuid (2),
821 .BR sigaction (2),
822 .BR sigprocmask (2),
823 .BR posix_spawn_file_actions_addclose (3),
824 .BR posix_spawn_file_actions_adddup2 (3),
825 .BR posix_spawn_file_actions_addopen (3),
826 .BR posix_spawn_file_actions_destroy (3),
827 .BR posix_spawn_file_actions_init (3),
828 .BR posix_spawnattr_destroy (3),
829 .BR posix_spawnattr_getflags (3),
830 .BR posix_spawnattr_getpgroup (3),
831 .BR posix_spawnattr_getschedparam (3),
832 .BR posix_spawnattr_getschedpolicy (3),
833 .BR posix_spawnattr_getsigdefault (3),
834 .BR posix_spawnattr_getsigmask (3),
835 .BR posix_spawnattr_init (3),
836 .BR posix_spawnattr_setflags (3),
837 .BR posix_spawnattr_setpgroup (3),
838 .BR posix_spawnattr_setschedparam (3),
839 .BR posix_spawnattr_setschedpolicy (3),
840 .BR posix_spawnattr_setsigdefault (3),
841 .BR posix_spawnattr_setsigmask (3),
842 .BR pthread_atfork (3),
843 .IR <spawn.h> ,
844 Base Definitions volume of POSIX.1-2001,
845 .I http://www.opengroup.org/unix/online.html