Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>cwait() suspend calling process until child terminates</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 cwait()                 Suspend calling process until child terminates

 #include   <process.h>

 int        cwait(term_status, child_proc, resume_time)
 int *term_status;                   Pointer to termination status word
 int child_proc;                     Child process to wait for
 int resume_time;                    When parent to resume execution

    cwait() suspends the calling process until the specified child
    process terminates. Note that cwait() is supported in OS/2 protected
    mode only. The argument values and meanings  are as follows:

 term_status:   If term-status is non-zero it points to a buffer
                containing the termination-status word and return code of
                the terminated child process.

                The termination-status word indicates whether or not the
                child process terminated normally by calling the OS/2
                DOSEXIT() function. If it did, the low-order and high-
                order bytes of the termination-status word are as
                follows:

                Byte          Contents  (Normal child termination)
                ---------     ------------------------------------------
                Low-order     0

                High-order    Contains the low-order byte of the result
                              code that the child code passed to DOSEXIT().
                              DOSEXIT() is called if the child process
                              called exit() or _exit(), returned from
                              main(), or reached the end of main().  The
                              low-order byte of the result code is either
                              the low-order byte of the argument to exit()
                              or _exit(), the low-order byte of the return
                              value from main(), or a random value if the
                              child process reached the end of main().

                Although DOSEXIT() allows programs to return a 16-bit
                result code, wait() and cwait() return only the low-order
                byte of that result code.

                If the child process terminated for any other reason, the
                low-order and high-order bytes of the termination-status
                word are as follows:

                Byte          Contents  (Abnormal child termination)
                ---------     ------------------------------------------
                Low-order     Termination code from DOSCWAIT():

                Code          Meaning
                -------       ----------------------------
                1             Hard-error abort
                2             Trap operation
                3             SIGTERM signal not intercepted

                High-order    0

 child_proc:    Specifies which child-process termination to wait for.
                This value is returned by the call to the spawn...()
                function that started the child process. If the specified
                child process terminates before the cwait() function is
                called, the function returns immediately.

 resume_time:   Specifies when the parent process resumes execution, as
                follows:
                Value                   Meaning
                ---------------         ---------------------------------
                WAIT_CHILD              The parent process waits until the
                                        specified child process has ended.

                WAIT_GRANDCHILD         The parent process waits until the
                                        specified child process and all of
                                        the child processes of that child
                                        process have ended.

    Returns:    If cwait() returns after abnormal termination of the
                child process, it returns -1 and sets errno to EINTR.

                If cwait() returns after normal termination of the child
                process, it returns the child's process ID.

                Otherwise cwait() returns -1 immediately and sets errno
                to one of the following error codes:

                Value                   Meaning
                ---------------         ---------------------------------
                    EINVAL              Invalid action code
                    ECHILD              No child process exists, or invalid
                                        process ID

 Portability:   OS/2 protected mode only.


See Also: wait() exit() _exit() spawn...()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson