The DosWaitChild() function allows a thread within a process to wait upon the termination of an asynchronous child process, in a similar manner to the DosWaitThread() function. The DosWaitChild() function allows a thread to wait for the termination of a single child process, or the termination of an entire process tree (that is, a process and all of its descendants).
Note that only the calling thread in the parent process is suspended during a DosWaitChild() call. If the parent process has other threads, they will continue to be dispatched.
The DosWaitChild() function can also be used to check the termination status of a child process that has already terminated, provided that process was started with the EXEC_ASYNCRESULT flag specified in the DosExecPgm() call. The use of this flag causes OS/2 to store the result code from the child process, for future reference by a DosWaitChild() call.
An example of the DosWaitChild() function is given in Figure "DosWaitChild() Function". Specifying the DCWA_PROCESS flag in the first parameter of the DosWaitChild() call causes the calling thread to wait only upon the specified process, and not upon its children (if any). If a thread is to wait upon the entire process tree, the DCWA_PROCESSTREE flag must be specified.
The DCWW_WAIT flag in the second parameter causes the calling thread to wait until the specified process has terminated. The DCWW_NOWAIT flag would cause the DosWaitChild() call to return immediately, without waiting for a child process to end. The DCWW_NOWAIT flag is typically used when checking the termination status of a child process that has already ended.