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>wait() suspend calling process until child terminates</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 wait()                  Suspend Calling Process Until Child Terminates

 #include   <process.h>

 int        wait(term_status)
 int *term_status;                       Pointer to termination status word

    wait() suspends the calling process until any of the caller's
    immediate child processes terminate. Note that wait() is supported in
    OS/2 protected mode only. The value and meaning of term_status is 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


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

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

                Otherwise wait() returns -1 immediately and sets errno to
                ECHILD, indicating that no child processes exist for the
                calling process.

 Portability:   OS/2 protected mode only.


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

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