1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1993 by Thomas Koenig <ig25@rz.uni-karlsruhe.de>
4 .\" and Copyright (c) 2004 by Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified Sat Jul 24 13:30:06 1993 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified Sun Aug 21 17:42:42 1994 by Rik Faith <faith@cs.unc.edu>
29 .\" (Thanks to Koen Holtman <koen@win.tue.nl>)
30 .\" Modified Wed May 17 15:54:12 1995 by Rik Faith <faith@cs.unc.edu>
31 .\" To remove *'s from status in macros (Thanks to Michael Shields).
32 .\" Modified as suggested by Nick Duffek <nsd@bbc.com>, aeb, 960426
33 .\" Modified Mon Jun 23 14:09:52 1997 by aeb - add EINTR.
34 .\" Modified Thu Nov 26 02:12:45 1998 by aeb - add SIGCHLD stuff.
35 .\" Modified Mon Jul 24 21:37:38 2000 by David A. Wheeler
36 .\" <dwheeler@dwheeler.com> - noted thread issues.
37 .\" Modified 26 Jun 01 by Michael Kerrisk
38 .\" Added __WCLONE, __WALL, and __WNOTHREAD descriptions
39 .\" Modified 2001-09-25, aeb
40 .\" Modified 26 Jun 01 by Michael Kerrisk, <mtk.manpages@gmail.com>
41 .\" Updated notes on setting disposition of SIGCHLD to SIG_IGN
43 .\" Added waitid(2); added WCONTINUED and WIFCONTINUED()
44 .\" Added text on SA_NOCLDSTOP
45 .\" Updated discussion of SA_NOCLDWAIT to reflect 2.6 behavior
46 .\" Much other text rewritten
47 .\" 2005-05-10, mtk, __W* flags can't be used with waitid()
48 .\" 2008-07-04, mtk, removed erroneous text about SA_NOCLDSTOP
50 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya all rights reserved.
51 .\" Japanese Version Copyright (c) 2005 Akihiro MOTOKI all rights reserved.
52 .\" Translated 1997-03-04, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
53 .\" Modified 2000-09-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
54 .\" Updated 2001-06-25, Kentaro Shirakata <argrath@ub32.org>
55 .\" Updated 2001-10-15, Kentaro Shirakata <argrath@ub32.org>
56 .\" Updated 2001-12-13, Kentaro Shirakata <argrath@ub32.org>
57 .\" Updated 2002-10-21, Kentaro Shirakata <argrath@ub32.org>
58 .\" Updated 2003-01-27, Kentaro Shirakata <argrath@ub32.org>
59 .\" Updated 2003-09-12, Kentaro Shirakata <argrath@ub32.org>
60 .\" Updated 2005-03-19, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
61 .\" Updated 2005-12-26, Akihiro MOTOKI
62 .\" Updated 2008-07-31, Akihiro MOTOKI, LDP v3.05
64 .\"WORD: signal handling シグナル処理
65 .\"WORD: suspend 停止(suspend)
66 .\"WORD: zombie ゾンビ(zombie)
67 .\"WORD: child process 子プロセス
68 .\"WORD: process group プロセス・グループ
69 .\"WORD: process group ID プロセス・グループID
70 .\"WORD: stop 停止(stop)
71 .\"WORD: effective user ID 実効ユーザーID
72 .\"WORD: block 禁止(block)
74 .TH WAIT 2 2010-09-26 "Linux" "Linux Programmer's Manual"
77 .\"O wait, waitpid, waitid \- wait for process to change state
78 wait, waitpid, waitid \- プロセスの状態変化を待つ
81 .B #include <sys/types.h>
83 .B #include <sys/wait.h>
85 .BI "pid_t wait(int *" "status" );
87 .BI "pid_t waitpid(pid_t " pid ", int *" status ", int " options );
89 .BI "int waitid(idtype_t " idtype ", id_t " id \
90 ", siginfo_t *" infop ", int " options );
93 .\"O Feature Test Macro Requirements for glibc (see
94 .\"O .BR feature_test_macros (7)):
96 .RB ( feature_test_macros (7)
105 _XOPEN_SOURCE\ >=\ 500 ||
106 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
108 .\"O || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
109 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L
115 .\"O All of these system calls are used to wait for state changes
116 .\"O in a child of the calling process, and obtain information
117 .\"O about the child whose state has changed.
118 .\"O A state change is considered to be: the child terminated;
119 .\"O the child was stopped by a signal; or the child was resumed by a signal.
120 .\"O In the case of a terminated child, performing a wait allows
121 .\"O the system to release the resources associated with the child;
122 .\"O if a wait is not performed, then the terminated child remains in
123 .\"O a "zombie" state (see NOTES below).
124 これらのシステムコールはいずれも、呼び出し元プロセスの子プロセスの
125 状態変化を待ち、状態が変化したその子プロセスの情報を取得するのに
128 子プロセスの終了、シグナルによる子プロセスの停止、
130 子プロセスが終了した場合は、wait を実行することで、
131 システムがその子プロセスに関連するリソースを解放できるようになる。
132 wait が実行されなかった場合には、終了した子プロセスは
133 「ゾンビ」状態で残り続ける (下記の注意の章を参照のこと)。
135 .\"O If a child has already changed state, then these calls return immediately.
136 .\"O Otherwise they block until either a child changes state or
137 .\"O a signal handler interrupts the call (assuming that system calls
138 .\"O are not automatically restarted using the
141 .\"O .BR sigaction (2)).
142 .\"O In the remainder of this page, a child whose state has changed
143 .\"O and which has not yet been waited upon by one of these system
146 子プロセスの状態変化がすでに発生していた場合、これらのコールは
147 すぐに復帰する。それ以外の場合は、子プロセスの状態変化が起こるか、
148 シグナルハンドラによりシステムコールが中断されるまで、
153 フラグによりシステムコールが自動的に再スタートするようになっていない
155 以下の説明では、状態変化が起こったがこれらのシステムコールのいずれかに
159 .\"O .SS "wait() and waitpid()"
160 .SS "wait() と waitpid()"
163 .\"O system call suspends execution of the calling process until one of its
164 .\"O children terminates.
166 .\"O .I wait(&status)
167 .\"O is equivalent to:
170 .\"O watpid(\-1, &status, 0);
173 システムコールは、子プロセスのいずれかが終了するまで
174 呼び出し元のプロセスの実行を一時停止する。
180 waitpid(\-1, &status, 0);
185 .\"O system call suspends execution of the calling process until a
186 .\"O child specified by
188 .\"O argument has changed state.
191 .\"O waits only for terminated children, but this behavior is modifiable
194 .\"O argument, as described below.
198 引き数で指定した子プロセスの状態変化が起こるまで、
199 呼び出し元のプロセスの実行を一時停止する。デフォルトでは、
201 は子プロセスの終了だけを待つが、この動作は
211 .\"O meaning wait for any child process whose process group ID is
212 .\"O equal to the absolute value of
216 の絶対値に等しい子プロセスのいずれかが終了するまでを待つ。
218 .\"O meaning wait for any child process.
221 .\"O meaning wait for any child process whose process group ID is
222 .\"O equal to that of the calling process.
223 プロセスグループID が呼び出したプロセスのものと等しい
226 .\"O meaning wait for the child whose process ID is equal to the
235 .\"O is an OR of zero or more of the following constants:
237 の値は次の定数の 0 個以上の論理和である:
240 .\"O return immediately if no child has exited.
241 状態変化が起こった子プロセスがない場合にすぐに復帰する。
244 .\"O also return if a child has stopped
245 .\"O (but not traced via
246 .\"O .BR ptrace (2)).
249 .\"O children which have stopped is provided
250 .\"O even if this option is not specified.
251 子プロセスが停止した場合にも復帰する (子プロセスが
254 このオプションが指定されていない場合でも、停止したプロセスが
255 「トレース (traced)」されていれば、子プロセスの状態が報告される。
257 .\"O .BR WCONTINUED " (Since Linux 2.6.10)"
258 .BR WCONTINUED " (Linux 2.6.10 以降)"
259 .\"O also return if a stopped child has been resumed by delivery of
265 .\"O (For Linux-only options, see below.)
266 (Linux 専用オプションについては後述する)
274 .\"O store status information in the \fIint\fP to which it points.
282 で指す \fIint\fP に状態情報を格納する。
283 .\"O This integer can be inspected with the following macros (which
284 .\"O take the integer itself as an argument, not a pointer to it,
288 .\"O .BR waitpid ()!):
289 この整数は以下のマクロを使って検査できる。
294 が書き込んだ整数そのものを指定する。ポインタではない!)
296 .BI WIFEXITED( status )
297 .\"O returns true if the child terminated normally, that is,
302 .\"O or by returning from main().
303 子プロセスが正常に終了した場合に真を返す。
311 .BI WEXITSTATUS( status )
312 .\"O returns the exit status of the child.
313 .\"O This consists of the least significant 8 bits of the
315 .\"O argument that the child specified in a call to
319 .\"O or as the argument for a return statement in main().
320 .\"O This macro should only be employed if
330 の呼び出し時に渡された値、もしくは main() の return 文の
336 .BI WIFSIGNALED( status )
337 .\"O returns true if the child process was terminated by a signal.
338 子プロセスがシグナルにより終了した場合に真を返す。
340 .BI WTERMSIG( status )
341 .\"O returns the number of the signal that caused the child process to
343 .\"O This macro should only be employed if
346 子プロセス終了の原因となったシグナルの番号を返す。
351 .BI WCOREDUMP( status )
352 .\"O returns true if the child produced a core dump.
353 .\"O This macro should only be employed if
356 .\"O This macro is not specified in POSIX.1-2001 and is not available on
357 .\"O some UNIX implementations (e.g., AIX, SunOS).
358 .\"O Only use this enclosed in #ifdef WCOREDUMP ... #endif.
359 子プロセスがコアダンプを生成した場合に真を返す。
363 このマクロは POSIX.1-2001 では規定されておらず、
364 (AIX, SunOS などの) いくつかの UNIX の実装では利用できない。
365 必ず #ifdef WCOREDUMP ... #endif で括って使用すること。
367 .BI WIFSTOPPED( status )
368 .\"O returns true if the child process was stopped by delivery of a signal;
369 .\"O this is only possible if the call was done using
371 .\"O or when the child is being traced (see
372 .\"O .BR ptrace (2)).
373 子プロセスがシグナルの配送により停止した場合に真を返す。
376 を指定して呼び出された場合か、子プロセスがトレースされている場合
380 .BI WSTOPSIG( status )
381 .\"O returns the number of the signal which caused the child to stop.
382 .\"O This macro should only be employed if
385 子プロセスを停止させたシグナルの番号を返す。
388 が 0 以外を返した場合だけにすべきである。
390 .BI WIFCONTINUED( status )
391 .\"O (since Linux 2.6.10)
393 .\"O returns true if the child process was resumed by delivery of
401 .\"O system call (available since Linux 2.6.9) provides more precise
402 .\"O control over which child state changes to wait for.
404 システムコール (Linux 2.6.9 以降で利用可能) を使うと、
405 子プロセスのどの状態変化を待つかについてより細かな制御ができる。
411 .\"O arguments select the child(ren) to wait for, as follows:
417 .IP "\fIidtype\fP == \fBP_PID\fP"
418 .\"O Wait for the child whose process ID matches
423 .IP "\fIidtype\fP == \fBP_PGID\fP"
424 .\"O Wait for any child whose process group ID matches
429 .IP "\fIidtype\fP == \fBP_ALL\fP"
430 .\"O Wait for any child;
437 .\"O The child state changes to wait for are specified by ORing
438 .\"O one or more of the following flags in
440 子プロセスのどの状態変化を待つかは以下のフラグで指定する
442 には 1個以上のフラグの論理和をとって指定する):
445 .\"O Wait for children that have terminated.
449 .\"O Wait for children that have been stopped by delivery of a signal.
450 子プロセスがシグナルの配送により停止するのを待つ。
453 .\"O Wait for (previously stopped) children that have been
454 .\"O resumed by delivery of
460 .\"O The following flags may additionally be ORed in
473 .\"O Leave the child in a waitable state; a later wait call
474 .\"O can be used to again retrieve the child status information.
475 waitable 状態のプロセスをそのままにする。この後で wait コールを
476 使って、同じ子プロセスの状態情報をもう一度取得することができる。
478 .\"O Upon successful return,
480 .\"O fills in the following fields of the
482 .\"O structure pointed to by
493 .\"O The process ID of the child.
497 .\"O The real user ID of the child.
498 .\"O (This field is not set on most other implementations.)
500 (このフィールドは他のほとんどの実装では設定されない)。
510 .\"O Either the exit status of the child, as given to
514 .\"O or the signal that caused the child to terminate, stop, or continue.
517 .\"O field can be used to determine how to interpret this field.
521 に指定された子プロセスの終了ステータス、もしくは
522 子プロセスの終了、停止、再開の原因となったシグナルが設定される。
533 .\"O (child killed by signal);
535 .\"O (child killed by signal, and dumped core);
537 .\"O (child stopped by signal);
539 .\"O (traced child has trapped); or
540 .\"O .B CLD_CONTINUED
541 .\"O (child continued by
549 (シグナルにより子プロセスが kill された);
551 (シグナルにより子プロセスが kill され、コア・ダンプが行われた);
555 (トレースされていた子プロセスがトラップを受信した);
562 .\"O was specified in
564 .\"O and there were no children in a waitable state, then
566 .\"O returns 0 immediately and
567 .\"O the state of the
569 .\"O structure pointed to by
576 waitable 状態の子プロセスがなかった場合には、
583 .\"O .\" POSIX.1-2001 leaves this possibility unspecified; most
584 .\"O .\" implementations (including Linux) zero out the structure
585 .\"O .\" in this case, but at at least one implementation (AIX 5.1)
586 .\"O .\" does not -- MTK Nov 04
587 .\" POSIX.1-2001 では、不定の可能性を残している。
588 .\" (Linux を含む) ほとんどの実装では、この場合に構造体を 0 で埋めるが、
589 .\" 少なくとも一つの実装 (AIX 5.1) ではそうならない。 -- MTK Nov 04
590 .\"O To distinguish this case from that where a child was in a
591 .\"O waitable state, zero out the
593 .\"O field before the call and check for a nonzero value in this field
594 .\"O after the call returns.
595 この場合を waitable 状態の子プロセスがあった場合と区別するには、
599 を 0 にしておき、コールが復帰した後でこのフィールドが 0 以外の値かどうか
601 .\"O .SH "RETURN VALUE"
604 .\"O on success, returns the process ID of the terminated child;
605 .\"O on error, \-1 is returned.
606 成功すると、終了した子プロセスのプロセスID を返す。
610 .\"O on success, returns the process ID of the child whose state has changed;
613 .\"O was specified and one or more child(ren) specified by
615 .\"O exist, but have not yet changed state, then 0 is returned.
616 .\"O On error, \-1 is returned.
617 成功すると、状態が変化した子プロセスのプロセスID を返す。
621 で指示された子プロセスが一つ以上存在するが、どの子プロセスでも
622 状態変化が起こっていなかった場合は、 0 を返す。
626 .\"O returns 0 on success or
629 .\"O was specified and no child(ren) specified by
631 .\"O has yet changed state;
632 .\"O on error, \-1 is returned.
637 で指示された子プロセスで状態変化が起こっていなかった場合にも
640 .\" FIXME: As reported by Vegard Nossum, if infop is NULL, then waitid()
641 .\" returns the PID of the child. Either this is a bug, or it is intended
642 .\" behavior that needs to be documented. See my Jan 2009 LKML mail
643 .\" "waitid() return value strangeness when infop is NULL".
644 .\"O Each of these calls sets
646 .\"O to an appropriate value in the case of an error.
647 エラーの場合、これらのシステムコールはいずれも
659 .\"O The calling process does not have any unwaited-for children.
660 呼び出し元プロセスには、wait を行っていない子プロセスはない。
672 .\"O The process specified by
674 .\"O .RB ( waitpid ())
679 .\"O .RB ( waitid ())
680 .\"O does not exist or is not a child of the calling process.
681 .\"O (This can happen for one's own child if the action for
685 .\"O See also the \fILinux Notes\fP section about threads.)
693 で指定したプロセスが存在しないか、呼び出し元プロセスの子プロセスでない
697 を設定した場合には、自分自身の子プロセスでも起こりうる。
698 スレッドに関しては「Linux での注意」の節も参照すること)。
702 .\"O was not set and an unblocked signal or a
704 .\"O was caught; see.
707 が設定されておらず、禁止 (block) されていないシグナルや
716 .\"O argument was invalid.
719 .\"O .SH "CONFORMING TO"
721 SVr4, 4.3BSD, POSIX.1-2001.
724 .\"O A child that terminates, but has not been waited for becomes a "zombie".
725 .\"O The kernel maintains a minimal set of information about the zombie
726 .\"O process (PID, termination status, resource usage information)
727 .\"O in order to allow the parent to later perform a wait to obtain
728 .\"O information about the child.
729 .\"O As long as a zombie is not removed from the system via a wait,
730 .\"O it will consume a slot in the kernel process table, and if
731 .\"O this table fills, it will not be possible to create further processes.
732 .\"O If a parent process terminates, then its "zombie" children (if any)
735 .\"O which automatically performs a wait to remove the zombies.
736 終了したが、wait されていない子プロセスは「ゾンビ」になる。
737 後で親プロセスが wait を実行して子プロセスについての情報を取得できるように、
738 カーネルはゾンビプロセスについて最小限の情報 (PID、終了ステータス、
740 ゾンビプロセスは、 wait によってシステムから削除されない限り、
741 カーネルのプロセステーブルの 1 エントリを消費する。このプロセステーブルが
742 一杯になると、新たにプロセスを作ることができなくなる。
743 親プロセスが終了すると、その親プロセスの「ゾンビ」の
748 は wait を自動的に実行し、ゾンビを削除する。
750 .\"O POSIX.1-2001 specifies that if the disposition of
759 .\"O .BR sigaction (2)),
760 .\"O then children that terminate do not become zombies and a call to
764 .\"O will block until all children have terminated, and then fail with
768 POSIX.1-2001 では以下のように規定されている。
778 参照)、終了した子プロセスはゾンビにはならず、
782 の呼び出しは全ての子プロセスが終了するまで停止し、
788 .\"O (The original POSIX standard left the behavior of setting
793 .\"O Note that even though the default disposition of
795 .\"O is "ignore", explicitly setting the disposition to
797 .\"O results in different treatment of zombie process children.)
802 を設定した場合の振る舞いを未規定のままにしている。
804 のデフォルトの動作が「無視」であるにもかかわらず、
808 を明示的に設定した場合にはゾンビプロセスの子プロセスの扱いが
810 .\"O Linux 2.6 conforms to this specification.
811 .\"O However, Linux 2.4 (and earlier) does not:
812 Linux 2.6 はこの仕様に準拠している。
813 しかし、Linux 2.4 (とそれ以前のバージョン) はそうではない:
818 .\"O call is made while
820 .\"O is being ignored, the call behaves just as though
822 .\"O were not being ignored, that is, the call blocks until the next child
823 .\"O terminates and then returns the process ID and status of that child.
832 つまり、呼び出しによって次の子プロセスの終了までブロックされ、
833 終了した子プロセスの PID と状態が返される。
836 .\"O In the Linux kernel, a kernel-scheduled thread is not a distinct
837 .\"O construct from a process.
838 .\"O Instead, a thread is simply a process
839 .\"O that is created using the Linux-unique
841 .\"O system call; other routines such as the portable
842 .\"O .BR pthread_create (3)
843 .\"O call are implemented using
845 .\"O they cannot be used with
847 Linux カーネルでは、カーネルによってスケジュールされるスレッドは
848 プロセスと明確に区別できる構成要素ではない。スレッドは Linux 固有の
850 システムコールを使用して生成されるプロセスに過ぎない。
852 .BR pthread_create (3)
859 .\"O Before Linux 2.4, a thread was just a special case of a process,
860 .\"O and as a consequence one thread could not wait on the children
861 .\"O of another thread, even when the latter belongs to the same thread group.
862 Linux 2.4 より前では、スレッドは単に特殊なプロセスであったので、
864 あるスレッドが別のスレッドの子プロセスが終了するのを待つことは出来なかった。
865 .\"O However, POSIX prescribes such functionality, and since Linux 2.4
866 .\"O a thread can, and by default will, wait on children of other threads
867 .\"O in the same thread group.
868 しかし、POSIX ではこのような機能を規定しており、
869 Linux 2.4 以降では、あるスレッドが同じスレッドグループの他のスレッドの
870 子プロセスが終了するのを待つことができるようになった。
871 そして将来はこれがデフォルトの動作になるであろう。
873 .\"O The following Linux-specific
875 .\"O are for use with children created using
878 を用いて作られた子プロセスには、以下の Linux 固有の
884 .\"O Wait for "clone" children only.
885 .\"O If omitted then wait
886 .\"O for "non-clone" children only.
887 .\"O (A "clone" child is one
888 .\"O which delivers no signal, or a signal other than
890 .\"O to its parent upon termination.)
892 指定されなかった場合は非 "clone" な子プロセスだけを待つ
893 ("clone" な子プロセスは、終了時に親プロセスへ全くシグナルを送らないか、
896 .\"O This option is ignored if
898 .\"O is also specified.
903 .\"O .BR __WALL " (since Linux 2.4)"
904 .BR __WALL " (Linux 2.4 以降)"
905 .\" since patch-2.3.48
906 .\"O Wait for all children, regardless of
907 .\"O type ("clone" or "non-clone").
908 "clone" であるかないかに関わらず、
911 .\"O .BR __WNOTHREAD " (since Linux 2.4)"
912 .BR __WNOTHREAD " (Linux 2.4 以降)"
913 .\" since patch-2.4.0-test8
914 .\"O Do not wait for children of other threads in
915 .\"O the same thread group.
916 .\"O This was the default before Linux 2.4.
917 同じスレッドグループの他のスレッドの子プロセスは待たない。
918 Linux 2.4 より前ではデフォルトであった。
921 .\"O .\" fork.2 refers to this example program.
922 .\" fork.2 もこのサンプルプログラムを参照している。
923 .\"O The following program demonstrates the use of
927 .\"O The program creates a child process.
928 .\"O If no command-line argument is supplied to the program,
929 .\"O then the child suspends its execution using
931 .\"O to allow the user to send signals to the child.
932 .\"O Otherwise, if a command-line argument is supplied,
933 .\"O then the child exits immediately,
934 .\"O using the integer supplied on the command line as the exit status.
935 .\"O The parent process executes a loop that monitors the child using
937 .\"O and uses the W*() macros described above to analyze the wait status value.
944 コマンドライン引き数が指定されなかったときは、
947 を使ってその実行を一時停止し、ユーザがその子プロセスに
951 コマンドラインで指定された整数を終了ステータスとして使用する。
955 wait のステータス値を上記の W*() マクロを使って解析するという
958 .\"O The following shell session demonstrates the use of the program:
959 下記ののシェル・セッションはプログラムの実行例である:
966 .RB "$" " kill \-STOP 32360"
968 .RB "$" " kill \-CONT 32360"
970 .RB "$" " kill \-TERM 32360"
976 .\"O .SS Program source
980 #include <sys/wait.h>
986 main(int argc, char *argv[])
997 if (cpid == 0) { /* Code executed by child */
998 printf("Child PID is %ld\\n", (long) getpid());
1000 pause(); /* Wait for signals */
1001 _exit(atoi(argv[1]));
1003 } else { /* Code executed by parent */
1005 w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
1011 if (WIFEXITED(status)) {
1012 printf("exited, status=%d\\n", WEXITSTATUS(status));
1013 } else if (WIFSIGNALED(status)) {
1014 printf("killed by signal %d\\n", WTERMSIG(status));
1015 } else if (WIFSTOPPED(status)) {
1016 printf("stopped by signal %d\\n", WSTOPSIG(status));
1017 } else if (WIFCONTINUED(status)) {
1018 printf("continued\\n");
1020 } while (!WIFEXITED(status) && !WIFSIGNALED(status));
1035 .BR pthread_create (3),
1036 .BR credentials (7),