2 Copyright © 2004-2011, 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>
13 #include "__arosc_privdata.h"
15 #include <sys/types.h>
18 /*****************************************************************************
29 Waits for child process to change state. State change is one of the
30 following events: child has exited, child was terminated by a signal,
31 child was stopped by a signal, child was resumed by a signal.
33 The function stores status of the process that changed state in the
34 pointer given as status argument.
36 The following macros can be used to extract information from the
39 WIFEXITED(status) - true if the process has exited
40 WEXITSTATUS(status) - exit status of the exited process
41 WIFSIGNALED(status) - true if the child process was terminated by a
43 WTERMSIG(status) - number of the signal that caused process
45 WIFSTOPPED(status) - true if the child process was stopped by a
47 WSTOPSIG(status) - number of the signal that caused child process
49 WIFCONTINUED(status) - true if the child process was resumed by the
52 Parent process will be suspended until a child changes state. If a
53 child process has already changed state, function returns immediately.
56 status - Pointer to int where child return status will be stored or
57 NULL if you don't want to store status.
60 Process id of the child process on success or -1 on error. If an error
61 occurred, the global variable errno is set.
64 This function will work only for child processeses notifying parent
65 process of their death, for example processes created by vfork() call.
66 If you want to use it for other processes, remember to set the
67 NP_NotifyOnDeath tag value to TRUE during child process creation.
77 Since POSIX signals are not yet implemented, WIFSIGNALED, WIFSTOPPED
78 and WIFCONTINUED macros always return 0. WIFEXITED always returns 1.
80 The et_UniqueID field of the ETask structure is used as process id.
82 ******************************************************************************/
89 et
= GetETask(FindTask(NULL
));
92 /* only ETasks are fertile */
97 et
= (struct ETask
*)ChildWait(0);
98 if (et
!= (struct ETask
*)CHILD_NOTNEW
)
102 *status
= et
->et_Result1
;
104 ret
= et
->et_UniqueID
;
105 ChildFree(et
->et_UniqueID
);