#include <sys/types.h> #include <sys/wait.h> pid_t wait(int *stat_loc);
The wait() function suspends processing until a child process has ended. The calling thread will suspend processing until status information is available for a child process that ended. A suspended wait() function call can be interrupted by the delivery of a signal whose action is either to run a signal-catching function or to terminate the process. When wait() is successful, status information about how the child process ended (for example, whether the process ended *stat_loc.
WIFEXITED(stat_val) | Evaluates to a nonzero value if the status was
returned for a child process that ended normally. |
WEXITSTATUS(stat_val) | If the value of the WIFEXITED(stat_val)
is nonzero, evaluates to the low-order 8 bits of the status argument that the
child process passed to exit(), or to the value the child
process returned from main(). |
WIFSIGNALED(stat_val) | Evaluates to a nonzero value if the status was
returned for a child process that ended because of the receipt of a terminating
signal that was not caught by the process. |
WTERMSIG(stat_val) | If the value of WIFSIGNALED(stat_val) is
nonzero, evaluates to the number of the signal that caused the child process to
end. |
WIFStopPED(stat_val) | Evaluates to a nonzero value if the status was
returned for a child process that is currently stopped. |
WStopSIG(stat_val) | If the value of the WIFStopPED(stat_val)
is nonzero, evaluates to the number of the signal that caused the child process
to stop. |
WIFEXCEPTION(stat_val) | Evaluates to a nonzero value if the status was
returned for a child process that ended because of an error condition.
Note: The WIFEXCEPTION macro is unique to the i5/OS implementation. See the Usage Notes. |
WEXCEPTNUMBER(stat_val) | If the value of the
WIFEXCEPTION(stat_val) is nonzero, this macro evaluates to the last
i5/OS exception number related to the child process.
Note: The WEXCEPTNUMBER macro is unique to the i5/OS implementation. See the Usage Notes. |
None
value | wait() was successful. The value returned indicates the process ID of the child process whose status information *stat_loc. |
-1 | wait() was not successful. The errno value is set to indicate the error. |
If wait() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
Calling process has no remaining child processes on which wait operation can be performed.
The address used for an argument is not correct.
In attempting to use an argument in a call, the system detected an address that is not valid.
While attempting to access a parameter passed to this function, the system detected an address that is not valid.
Interrupted function call.
Unknown system state.
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.
then the parent's wait() stat_loc value indicates that:
See Code disclaimer information for information pertaining to code examples.
For an example of using this function, see Using the Spawn Process and Wait for Child Process APIs in API examples.
Top | UNIX-Type APIs | APIs by category |