--- os2sdk/demos/examples/cwait/cwait.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/cwait/cwait.c 2018/08/09 12:26:16 1.1.1.2 @@ -1,10 +1,10 @@ /* - * Example of DOSCWAIT usage. + * Example of DosCWait usage. * - * Although a process can only call DOSCWAIT on its own child processes, + * Although a process can only call DosCWait on its own child processes, * it is possible to wait indirectly on subsequent generations of * processes by use of the ProcessAndDescendents flag. To wait for a - * collection of subprocesses to end, a process must call DOSCWAIT + * collection of subprocesses to end, a process must call DosCWait * repeatedly, once for each of the subprocesses. The result codes * field is only valid for the one call first call against the child. * Subsequent calls indicate that another descendent process has ended, @@ -16,10 +16,13 @@ * * Compile as: cl -AL -G2 -Lp cwait.c * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include +#define INCL_DOSPROCESS + +#include +#include #include #define ERRBUF_LEN 64 @@ -27,8 +30,9 @@ main() { - struct ResultCodes child_status, child_pid; - unsigned ending_pid, res; + RESULTCODES child_status, child_pid; + PID ending_pid; + unsigned res; char errbuf[ERRBUF_LEN]; char child_arg[ARG_LEN]; char *child_env; @@ -36,26 +40,26 @@ main() /* * Execute a program and wait for it to finish. */ - DOSEXECPGM((char *)0, 0, 2, (char *)0, (char *)0, &child_pid, + DosExecPgm((char *)0, 0, 2, (char *)0, (char *)0, &child_pid, "child.exe"); printf("exec'd child, pid = %u\n", child_pid); - DOSCWAIT(0,0, &child_status, &ending_pid, child_pid.TermCode_PID); - if (child_status.TermCode_PID != 0) + DosCWait(0,0, &child_status, &ending_pid, child_pid.codeTerminate); + if (child_status.codeTerminate != 0) printf("error: child's termination code was %u\n", - child_status.TermCode_PID); + child_status.codeTerminate); else - printf("child process returned %u\n", child_status.ExitCode); + printf("child process returned %u\n", child_status.codeResult); /* * Execute a program and wait for it and all of its descendents * to finish. In this case we specify the top pid to wait for. */ - DOSEXECPGM((char *)0, 0, 2, (char *)0, (char *)0, &child_pid, + DosExecPgm((char *)0, 0, 2, (char *)0, (char *)0, &child_pid, "child.exe"); printf("exec'd child, pid = %u\n", child_pid); do { - res = DOSCWAIT(1,0, &child_status, &ending_pid, - child_pid.TermCode_PID); + res = DosCWait(1,0, &child_status, &ending_pid, + child_pid.codeTerminate); if(res == 0) printf("cwait found pid = %u\n", ending_pid); else @@ -66,11 +70,11 @@ main() * Wait for any child to terminate. In this case we specify * the pid as zero, which means wait for any child to finish. */ - DOSEXECPGM((char *)0, 0, 2, (char *)0, (char *)0, &child_pid, + DosExecPgm((char *)0, 0, 2, (char *)0, (char *)0, &child_pid, "child.exe"); printf("exec'd child, pid = %u\n", child_pid); do { - res = DOSCWAIT(1,0, &child_status, &ending_pid, 0); + res = DosCWait(1,0, &child_status, &ending_pid, 0); if (res == 0) printf("child %u ended\n", ending_pid); } while (res == 0);