The information in this article applies to:
SUMMARYIn the Microsoft C Compiler, there is no C run-time function that will return the system exit code from a child process. However, Interrupt 21h SubFunction 4Dh can be used to return it. MORE INFORMATIONImmediately after a child process terminates, the child exit code and the system exit code are in the AL and AH registers, respectively. For example:
When the spawn() family of functions is called with a mode flag of
P_WAIT, only the child exit code is returned. To read the system exit
code, a call to Interrupt 21h SubFunction 4Dh is needed.It is important to get and store the return codes immediately upon returning from the child process, because another function may modify them. The following code samples demonstrate how to get the exit code from the child process within the parent process with C. Sample Code 1
Sample Code 2
Because C version 6.0 and later have the feature of using inline assembly,
the AX register can be accessed directly without using any interrupts. The
following line of code can be used in place of the interrupt call:
Additional query words: kbinf 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50
Keywords : kb16bitonly |
Last Reviewed: December 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |