gtpc2m9jC/C++ Language Support User's Guide

WEXITSTATUS-Obtain Exit Status of a Child Process

This macro queries the child termination status provided by the wait and waitpid functions. If the WIFEXITED macro indicates that the child process exited normally, the WEXITSTATUS macro returns the exit code specified by the child process.

Format

#include <sys/wait.h>
int WEXITSTATUS(int status);

status
The status field that was filled in by the wait or waitpid function.

Normal Return

The WEXITSTATUS macro is always successful.

If the WIFEXITED macro indicates that the child process exited normally, the WEXITSTATUS macro returns the exit code specified by the child. If the WIFEXITED macro indicates that the child process did not exit normally, the value returned by the WEXITSTATUS macro has no meaning.

Error Return

Not applicable.

Programming Considerations

None.

Examples

See wait-Wait for Status Information from a Child Process for an example of the WEXITSTATUS macro.

Related Information