Wait for any child process to change its state
#include <sys/wait.h> #include <sys/resource.h> pid_t wait3( int * stat_loc, int options, struct rusage * resource_usage );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The wait3() function allows the calling thread to obtain status information for specified child processes.
|If the parent process sets the action for SIGCHLD to SIG_IGN, its children won't enter the zombie state, and it won't be able to use the wait*() functions to wait on their deaths.|
The following call:
wait3( stat_loc, options, resource_usage );
is equivalent to:
waitpid( (pid_t)-1, stat_loc, options );
except that on successful completion, if the resource_usage argument to wait3() isn't a null pointer, the rusage structure that the third argument points to is filled in for the child process identified by the return value.
It's also equivalent to:
wait4( (pid_t)-1, stat_loc, options, resource_usage );
The waitpid() function is POSIX: wait3() and wait4() are BSD extensions.
If the status of a child process is available, a value equal to the process ID of the child process for which status is reported.
If a signal is delivered to the calling process, -1 and errno is set to EINTR.
Zero if wait3() is invoked with WNOHANG set in options and at least one child process is specified by pid for which status isn't available, and status isn't available for any process specified by pid.
Otherwise, (pid_t)-1 and errno is set.
exit(), fork(), pause(), wait4(), waitid(), waitpid()
“Detecting process termination” in the “Processes” chapter of the QNX Neutrino Programmer's Guide