2 Copyright © 2004-2013, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include <aros/debug.h>
12 #include <sys/types.h>
15 /*****************************************************************************
26 Waits for child process to change state. State change is one of the
27 following events: child has exited, child was terminated by a signal,
28 child was stopped by a signal, child was resumed by a signal.
30 The function stores status of the process that changed state in the
31 pointer given as status argument.
33 The following macros can be used to extract information from the
36 WIFEXITED(status) - true if the process has exited
37 WEXITSTATUS(status) - exit status of the exited process
38 WIFSIGNALED(status) - true if the child process was terminated by a
40 WTERMSIG(status) - number of the signal that caused process
42 WIFSTOPPED(status) - true if the child process was stopped by a
44 WSTOPSIG(status) - number of the signal that caused child process
46 WIFCONTINUED(status) - true if the child process was resumed by the
49 Parent process will be suspended until a child changes state. If a
50 child process has already changed state, function returns immediately.
53 status - Pointer to int where child return status will be stored or
54 NULL if you don't want to store status.
57 Process id of the child process on success or -1 on error. If an error
58 occurred, the global variable errno is set.
61 This function will work only for child processeses notifying parent
62 process of their death, for example processes created by vfork() call.
63 If you want to use it for other processes, remember to set the
64 NP_NotifyOnDeath tag value to TRUE during child process creation.
74 Since POSIX signals are not yet implemented, WIFSIGNALED, WIFSTOPPED
75 and WIFCONTINUED macros always return 0. WIFEXITED always returns 1.
77 The et_UniqueID field of the ETask structure is used as process id.
79 ******************************************************************************/
86 et
= GetETask(FindTask(NULL
));
89 /* only ETasks are fertile */
94 et
= (struct ETask
*)ChildWait(0);
95 if (et
!= (struct ETask
*)CHILD_NOTNEW
)
99 *status
= et
->et_Result1
;
101 ret
= et
->et_UniqueID
;
102 ChildFree(et
->et_UniqueID
);