2 Copyright © 2004-2009, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include <aros/startup.h>
11 #include <aros/debug.h>
14 #include "__arosc_privdata.h"
16 #include <sys/types.h>
20 /*****************************************************************************
30 Waits for child process to change state. State change is one of the
31 following events: child has exited, child was terminated by a signal,
32 child was stopped by a signal, child was resumed by a signal.
34 The function stores status of the process that changed state in the
35 pointer given as status argument.
37 The following macros can be used to extract information from the
40 WIFEXITED(status) - true if the process has exited
41 WEXITSTATUS(status) - exit status of the exited process
42 WIFSIGNALED(status) - true if the child process was terminated by a
44 WTERMSIG(status) - number of the signal that caused process
46 WIFSTOPPED(status) - true if the child process was stopped by a
48 WSTOPSIG(status) - number of the signal that caused child process
50 WIFCONTINUED(status) - true if the child process was resumed by the
53 Parent process will be suspended until a child changes state. If a
54 child process has already changed state, function returns immediately.
57 status - Pointer to int where child return status will be stored or
58 NULL if you don't want to store status.
61 Process id of the child process on success or -1 on error. If an error
62 occurred, the global variable errno is set.
65 This function will work only for child processeses notifying parent
66 process of their death, for example processes created by vfork() call.
67 If you want to use it for other processes, remember to set the
68 NP_NotifyOnDeath tag value to TRUE during child process creation.
78 Since POSIX signals are not yet implemented, WIFSIGNALED, WIFSTOPPED
79 and WIFCONTINUED macros always return 0. WIFEXITED always returns 1.
81 The et_UniqueID field of the ETask structure is used as process id.
83 ******************************************************************************/
90 et
= GetETask(FindTask(NULL
));
93 /* only ETasks are fertile */
98 et
= (struct ETask
*)ChildWait(0);
99 if (et
!= (struct ETask
*)CHILD_NOTNEW
)
103 *status
= et
->et_Result1
;
105 ret
= et
->et_UniqueID
;
106 ChildFree(et
->et_UniqueID
);